-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
fix(select-query-parser): select left join and array instead of objects result types #553
Merged
soedirgo
merged 15 commits into
supabase:master
from
avallete:avallete/invalid-select-results-types
Sep 10, 2024
Merged
fix(select-query-parser): select left join and array instead of objects result types #553
soedirgo
merged 15 commits into
supabase:master
from
avallete:avallete/invalid-select-results-types
Sep 10, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reproduction based on supabase/supabase#29086
Chore docker-compose in ci and replace it by docker compose as recommended by: https://github.blog/changelog/2024-04-10-github-hosted-runner-images-deprecation-notice-docker-compose-v1/
soedirgo
reviewed
Sep 10, 2024
Thanks! I think this fixes supabase/supabase#29086 but not #546 - will investigate that separately |
soedirgo
approved these changes
Sep 10, 2024
🎉 This PR is included in version 1.16.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What kind of change does this PR introduce?
This PR improves the TypeScript typings generated by the SQL query parser, fixing issues with inferred types for certain
!left
joins and relationship queries (e.g.,created_by:users(*)
).What is the current behavior?
Currently, for certain queries, the inferred types for relations are incorrect. For instance, the type may be inferred as
{}[]
when the runtime result is a single object{}
.Related issues
#546
supabase/supabase#29086
What is the new behavior?
This PR updates the select-query-parser to handle these cases more accurately by:
!left
operator, similar to the existing logic for the!inner
operator.Additional context
The TypeScript code in select-query-parser is quite complex. I would appreciate a thorough review of this fix.
Additional tests have been added to cover both runtime and typing scenarios. This helped uncover more edge cases, some of which still need further solutions.
Known Issues:
Currently, there is no distinction between possibly nullable and non-nullable results for zero-to-one or one-to-one relations. To handle this properly, the PR always returns null as a possible option. However, a more accurate solution would involve enhancements like adding an
isOneToOne
option in Relationships that marks foreign keys as nullable or non-nullable based oncolumns[]
type definitions.PS
Also took the chance to fix the CI workflow by replacing the deprecated docker-compose with
docker compose
command.