8000 feat(compiler): Support LEFT JOIN on aliased table by kyleconroy · Pull Request #2873 · sqlc-dev/sqlc · GitHub
[go: up one dir, main page]

Skip to content

feat(compiler): Support LEFT JOIN on aliased table #2873

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

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

kyleconroy
Copy link
Collaborator

Fixes #1897

Comment on lines +427 to 434
tableMatch := *n.Relname == col.Table.Name
aliasMatch := true
if n.Alias != nil && col.TableAlias != "" {
aliasMatch = *n.Alias.Aliasname == col.TableAlias
}
if n.Alias != nil && *n.Alias.Aliasname == col.TableAlias && *n.Relname == col.Table.Name {
if aliasMatch && tableMatch {
return prior
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the column doesn't use a table alias, don't check that the aliases match.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems correct logically, although aliasMatch defaulting to true is potentially confusing to future readers. I might suggest just putting this comment you wrote in the actual source.