Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right vs left join #588

Open
jakubvojacek opened this issue Mar 23, 2023 · 2 comments
Open

Right vs left join #588

jakubvojacek opened this issue Mar 23, 2023 · 2 comments
Milestone

Comments

@jakubvojacek
Copy link
Contributor

Hello @staabm

 public function rightLeftJoin(PDO $pdo): void
    {
        $stmt = $pdo->query('SELECT adaid from ada left join ak on adaid = eladaid');
        assertType('PDOStatement<array{adaid: int<-32768, 32767>, 0: int<-32768, 32767>}>', $stmt);

        $stmt = $pdo->query('SELECT adaid from ak right join ada on adaid = eladaid');
        assertType('PDOStatement<array{adaid: int<-32768, 32767>, 0: int<-32768, 32767>}>', $stmt);
    }

I found one RIGHT JOIN in our codebase that colleague of mine used (I've never used right join actually, always just left/inner).

Anyway, if I understand it right, I should be able to switch left vs right when I switch the table names an get same results, or not?

I tried that using the test above but it fails the 2nd assertion with

-'PDOStatement<array{adaid: int<-32768, 32767>, 0: int<-32768, 32767>}>'
+'PDOStatement<array{adaid: int<-32768, 32767>|null, 0: int<-32768, 32767>|null}>'

But I dont think that adaid will ever be null, or will it?

@staabm
Copy link
Owner

staabm commented Mar 23, 2023

I never used right join personally. Have no idea when/why to use them

@staabm
Copy link
Owner

staabm commented Mar 25, 2023

to clarify: this should not mean that we don't want support for right joins, but it needs some more intensive testing on your end how the sql actually behaves and what types to expect

@staabm staabm added this to the SQL AST milestone Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants