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

Update JoinClauseMixin to support more ANSI SQL joins #616

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

griffio
Copy link
Contributor

@griffio griffio commented Mar 26, 2024

🦶Initial step to support cashapp/sqldelight#5086

Add Ansi Sql join operators RIGHT and FULL e.g Now supported in https://www.sqlite.org/releaselog/3_39_0.html

LATERAL modifier not included, as works in two different ways (table/subquery and join) and should be implemented as a separate feature

These are added as forward declarations in the SqlLexer.flex that are needed for dialects to override

🏰 Keep core grammar with LEFT join

This allows the existing dialects to work with LEFT join and enables dialects to add RIGHT, FULL where supported, e.g PostgreSql and latest Sqlite dialect

e.g Postgresql.bnf would override the core join_operator and adds right_join_operator

📸 Tested snapshot build with SqlDelight branch as this appears to work

join_operator ::= ( COMMA
                  | [ NATURAL ] [ ( {left_join_operator} | {right_join_operator} | {full_join_operator} ) [ OUTER ] | INNER | CROSS ] JOIN ) {
  extends = "com.alecstrong.sql.psi.core.psi.impl.SqlJoinOperatorImpl"
  implements = "com.alecstrong.sql.psi.core.psi.SqlJoinOperator"
  override = true
}

Add Ansi join operators RIGHT and FULL

Also LATERAL modifier

These are added as forward declarations in the SqlLexer.flex that are needed for dialects to override

Keep core grammar with LEFT join

This allows the existing dialects to work with LEFT join and enables dialects to add RIGHT, FULL where supported, e.g PostgreSql and latest Sqlite dialect
@griffio griffio marked this pull request as draft March 27, 2024 13:59
LATERAL keyword is used as table/subquery and join operation.

Needs special handling
@griffio griffio marked this pull request as ready for review March 27, 2024 14:55
@hfhbd hfhbd merged commit 5c953c5 into AlecKazakova:master Mar 27, 2024
1 check passed
@griffio griffio deleted the add-ansi-join-operators branch March 27, 2024 15:48
@hfhbd hfhbd mentioned this pull request Apr 3, 2024
@hfhbd
Copy link
Collaborator

hfhbd commented Apr 5, 2024

Keep core grammar with LEFT join
This allows the existing dialects to work with LEFT join and enables dialects to add RIGHT, FULL where supported, e.g PostgreSql and latest Sqlite dialect

This was on purpose? Then we should revert #618, I didn't know some dialects do not support ANSI RIGHT or FULL...

@griffio
Copy link
Contributor Author

griffio commented Apr 5, 2024

Keep core grammar with LEFT join
This allows the existing dialects to work with LEFT join and enables dialects to add RIGHT, FULL where supported, e.g PostgreSql and latest Sqlite dialect

This was on purpose? Then we should revert #618, I didn't know some dialects do not support ANSI RIGHT or FULL...

Yes - see https://www.sqlite.org/releaselog/3_39_0.html

This was a way that the core grammar can be overridden easier by supporting dialects that have all joins (mysql doesn't support FULL)

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

Successfully merging this pull request may close these issues.

None yet

2 participants