Support nullable columns on Right Join and Full Join #626
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To enable a fix in sqldelight/sqldelight#5136
Tested locally and in SqlDelight using snapshot build
For unit testing in sql-psi, the
sql.bnf
grammar would have to includeright
andfull
joins - however, not all databases dialects supportfull
joins, sqlite recently addedright
joins. Actual tests would have to be added to SqlDelight with a supporting grammar such as Postgresql.Implementation
💇♂️ The existing code present in
queryExposed
is worked around rather than a complete re-write🤐 Uses zipWithNext to create a pair of table queries, if there are joins present in the query. These joins could be inner joins or outer joins. Only outer joins are copied with the
nullable
field set totrue
.👥 From each pair, when there is a
right
orfull join
the first query columns are copied with nullability, anyleft
orfull join
nullability columns are produced on the second query columnsThis produces duplicate QueryResult columns and
queryAvailable.associateBy { it.table }.values
is used to remove the duplicate columnsLEFT JOINS nulls on right expected and does so in table data interface
RIGHT JOINS nulls on left side expected and does have nullable types for A fields
FULL JOINS nulls on both sides expected and does have nullable types for A, B fields