-
Notifications
You must be signed in to change notification settings - Fork 803
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
Add support for emitting pointer types for nullable columns #1571
Add support for emitting pointer types for nullable columns #1571
Conversation
how can I try this out? I have been looking at the alternative which is to manually override but that is pretty tedious. would like to try this out just don't know how to include it. |
This was implemented before (named a bit differently), but it has been removed. #814 has a list of needed overrides. Which is a bit tedious to copy around I'd say. |
@mvrhov so is it just recommend to add them manually then I'm guessing? Thanks for this list as it does help. |
For now I guess. I do like this PR because then I don't have to copy a bunch of lines into each project. |
Certainly avoiding having to copying a bunch of lines around would be a huge improvement. Any chance this could be considered for a merge in your eyes, despite prior history, @mvrhov? |
@nickbruun It's not my decision on what's getting merged. |
@mvrhov I understand – mostly just wondering what historical context you can provide since it sounds like this was tried before? |
@nickbruun Sorry that I'm just getting around to getting this reviewed. I know it's been months since it was opened. I'm onboard with this change and would like to get it merged for the pgx/v5 release #1823 |
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.
How should this work in conjunction with the new pgtype package? I think we should only return pointers to non-pgtype types. Thoughts?
Let me review the changes from pgx/v5 and I'm happy to update in accordance :) |
would be good to have this feature in v5 |
Is this going to be merged soon? I'm using sqlc, gqlgen and gqlgenc, getting an error about String is incompatible with database/sql.NullString and I'd much rather use the pointers for null types. |
Oh wow, I totally got behind on developing a coherent view on pgx/v5. Thanks for merging this! |
pgx/v4 supports passing and scanning into pointer types for nullable columns instead of using the standard library
Null<Type>
representation, which is super handy if you wind up interfacing a lot with, say, generated Protocol Buffer files using the proto3optional
flag.This PR adds a new configuration option
emit_pointers_for_null_types
, which, as per the documentation line added:This change would be a significant quality-of-life improvement for me, but I obviously don't know if it generally fits with the philosophy of sqlc, so consider this a suggestion and please feel free to provide any feedback (including, but not limited to bike-shedding of the choice of name for the configuration parameter, if we see this feature fit for sqlc.)
Lastly, thanks all for building this tool. It's genuinely saved me tons of hours writing the same pesky boiler plate with limited guarantees.