-
Notifications
You must be signed in to change notification settings - Fork 848
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
Nullable datetimes are used for timestamps marked as not null in PGX / GO #3837
Comments
I would guess that the not null checks here should be moved up as the first check sqlc/internal/codegen/golang/postgresql_type.go Lines 236 to 246 in ec9d492
As it is with the string types sqlc/internal/codegen/golang/postgresql_type.go Lines 260 to 271 in ec9d492
Is there a reason that it issn't? If not, then I could go ahead and do the pr for this on all cases where the null check is below the pgx check |
Facing this same issue. This is a pretty urgent bug considering nullable timestamptz's are relatively common in Postgres and having them be represented as nil in Go is very idiomatic. |
@mcdoker18 I can see you authored the original part of this code in #1874, do you have any comments about the desired intent here? Great job by the way! I have some questions about linked PR's which breaks a lot of tests, the question is if the new output is the desired or not? Is it to big of a breaking change? should it be behind a new flag? |
Version
1.28.0
What happened?
For pgx,
pgtype.Timestamp
is used forTIMESTAMP
(and other time related types) regardless if the column is nullable or not.time.Time
was expected to be used for timestamps marked withNOT NULL
"database/sql" is handling it correctly https://play.sqlc.dev/p/e1e23e0d41d3d1340a4a009099bb81b589385b49187b89fd40c9aee4c33097cf
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/7ac654a59b8d17aa0f7e9bd8dfd689bec9d035bc8e8ea7a5a1beb078be531769
What operating system are you using?
No response
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: