You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure and I might be missing something, but null overrides at least for timestamp to *time.Time, doesn't seem to wok, text, to *string works.
I've also tried with timestamptz, timestamp(0), timestamp without time zone I'm unable to debug this as the go compiler fails when building debug version in Goland with OOM.. it seems that 8G of free ram is not enough.
edit: , jsonb to *json.RawMessage kinda works.. it generates two imports "encoding/json" and json "encoding/json"
I should have updated here. But I found my issue, essentially the params object which are generated for a function dont seem to respect overrides in some cases. The tables themselves were being generated with the right types. I was able to come up with a workaround, I outline it in sort of an exploratory stream of consciousness here: #950. I will be updating the ticket with a summary today.
This issue appears to be resolved in current versions, but since it remains open and is still discoverable through search engines. I wanted to summarize and document this workaround for anyone facing similar issues and suggest to close the issue if it is no longer relevant and this feature is already documented in the sqlc documentation.
Issue
When using emit_pointers_for_null_types: true with type overrides in sqlc, nullable columns don't generate pointer types as expected for cerain types. For example: pgtype.Timestamptz is generated for nullable timestamptz fields.
Solution
Adding an additional override entry with db_type.nullable: true and go_type.pointer: true resolved the issue:
Activity
[-]null overrides `timestamp` to `*time.Time` not working[/-][+]null pointer overrides not working[/+]mvrhov commentedon Feb 9, 2021
Meh.. this seems to somewhat work but it's tedious and almost impossible to guess.
jskelcy commentedon Mar 19, 2021
hmm I am trying to use this and its not working for me. Anything tricky you did here @mvrhov? In particular, I cant get timestamps to work.
mvrhov commentedon Mar 22, 2021
@jskelcy Are you saying, that the config one post above yours doesn't work for you?
jskelcy commentedon Mar 22, 2021
I should have updated here. But I found my issue, essentially the
paramsobject which are generated for a function dont seem to respect overrides in some cases. The tables themselves were being generated with the right types. I was able to come up with a workaround, I outline it in sort of an exploratory stream of consciousness here: #950. I will be updating the ticket with a summary today.Thanks for checking @mvrhov
ptman commentedon Mar 7, 2022
I'm not having success with using
*stringinstead ofNullString:mvrhov commentedon Mar 8, 2022
db_type: 'pg_catalog.text'should bedb_type: 'text'. Yeah I know it's a mess and mix of both depending on the type.kyleconroy commentedon Sep 22, 2023
Tracking documentation improvements for this #2762
lightSoulDev commentedon Jul 6, 2025
This issue appears to be resolved in current versions, but since it remains open and is still discoverable through search engines. I wanted to summarize and document this workaround for anyone facing similar issues and suggest to close the issue if it is no longer relevant and this feature is already documented in the sqlc documentation.
Issue
When using
emit_pointers_for_null_types: truewith type overrides in sqlc, nullable columns don't generate pointer types as expected for cerain types. For example:pgtype.Timestamptzis generated for nullable timestamptz fields.Solution
Adding an additional override entry with
db_type.nullable: trueandgo_type.pointer: trueresolved the issue:Example
Given this SQL schema:
The generated Go struct now correctly uses pointer types for nullable fields:
Without the nullable override,
DeletedAtwould be generated aspgtype.Timestamptzinstead of*time.Time.