-
Notifications
You must be signed in to change notification settings - Fork 863
Update postgresql_type.go - check notNull and emitPointersForNull before SQLDriver #3839
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
base: main
Are you sure you want to change the base?
Conversation
…ore SQLDriver this fixes the issue where despite having emit_pointers_for_null_types set to true, the generate models don't use pointers for timestamp field.
Linked to issue #3837 I can see there is a lot of tests there fails, the question should then be if the new output is the desired or not? Is it to big of a breaking change? should it be behind a new flag? |
@theAnuragMishra maybe you could update the tests so it's easier to see the impact of this change? It needs to be updated anyway for it to get merged |
is there a way i can commandeer this? Seems author might be tied up? |
@acartine I think you'd be more than welcome to give it a go in a new PR |
ok i'll give it a shit. i'm on gmt+1 but hopefully it won't take too long |
really proud of my typo above, first class |
@benjaco from looking at the code more closely it appears there is an unclear configuration hierarchy if you look at the first few types in sqlc/internal/codegen/golang/postgresql_type.go Lines 44 to 139 in 047d587
the go types and emit-pointers-on-null supercede pgxv5 then for numerics/dates/times/uuid etc. that hierarchy is flipped. this leads to a confusing devx because sometimes you get the go types / pointers and sometimes you get the pgtypes, which are more cumbersome to work with. the latter reason is probably why we try to use go types for nonnulls regardless of whether or not it is pgxv5 for the literal types. i would think we need to draw some kind of line in the sand here and say there are two modes
is there a discord/slack for broader discussion about this? |
@acartine Issnt that what "emit_pointers_for_null_types" is suppose to configure?
So if There is no broader discussion, its all in the issue #3837 and in the pr's linked around that issue |
i think there is a bit more clarification need. would you prefer i do it on that issue instead of this one? in that issue you use the text/varchar example. And that's fine if that is the expected behavior. however it should be noted that that style means that that the pgtype is used only if the type is nullable and !emitPointersForNull. It will never be used if the type is notNull. that is a reasonably big change that will break any code that upgrades and does not use emitPointersForNull. but if that's how you want me to implement it i'm happy to do it that way. while we are at it, i can't seem to find a command to update the expected outputs, should I assume then that it is manual and not auto generated? |
@acartine lets move the discussion to the issue |
this fixes the issue where despite having emit_pointers_for_null_types set to true, the generate models don't use pointers for timestamp field.