-
Notifications
You must be signed in to change notification settings - Fork 881
feat: Add embedded structs based on result match #984
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
Conversation
Run |
This comment has been minimized.
This comment has been minimized.
Didn't realize the join handling hadn't reached master, but this will be a problem when #983 lands. Handling fields that are nullable after joins, but not nullable in the data model will be difficult with this approach. |
The embedded struct shouldn't be nullable though... right? It doesn't represent any data itself, simply a container for data. |
Correct. But the problem comes when After those PRs land, adding proper handling for each join case to this PR will be straightforward. It's possible those cases will be automatically taken care of by #983 before this code path is even reached, not quite sure implementation wise. |
Ahh understood. |
bump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is now out of date, there are merge conflicts.
Also, I'm not sure how you're planning on solving the LEFT JOIN issue. You can't use the existing structs because a non-nullable column can now be null. I think you'll need to generate new structs, which may defeat the entire purpose. Maybe we just don't allow embedding to work when using left joins?
Lastly, the syntax for this needs to be a special sqlc function. I'd suggest using sqlc.embed()
. The reason is that overloading the table.*
method isn't backwards compatible.
@kylecarbs I haven't heard from you in a while, so I'm going to close this out. If you end up working on this, please open a new pull request or push to this one and mention me in a comment. |
@kylecarbs I'm interesting in this feature. If you are not working on this anymore I can take it! |
Feel free! I'd love to tackle it but don't quite have bandwidth at the moment. |
Identifies every column with a returned struct for queries.
This is a breaking change. I'm very open to comments, ideas, or reasons why this shouldn't even happen. To prevent breakage we could move this under a configuration option, and eventually migrate to default in a major version.
Before:
After: