Closed
Description
Version
1.28.0
What happened?
Sqlc doesn't generate models based on the type overrides found in the configuration sqlc.yaml
. It doesn't accept the go type override for time.Time when the postgres type in the schema is a timestamp with time zone
, but accepts it when the postgres type is defined using the short hand timestamptz
.
Relevant log output
Database schema
-- doesn't work for this table as the generated model has a created_at pgtype.Timestamptz field
CREATE TABLE test (
id serial,
created_at timestamp with time zone not null
);
-- works for this table as the generated model has a created_at time.Time field
CREATE TABLE test2 (
id serial,
created_at timestamptz not null
);
SQL queries
Configuration
version: "2"
sql:
- engine: "postgresql"
schema: "./database/schema.sql"
queries: "./database/query"
gen:
go:
emit_json_tags: true
package: "bloc"
out: "database/sqlc/bloc"
sql_package: "pgx/v5"
overrides:
# Override PostgreSQL "timestamptz" to Go's time.Time
# Doesn't work if the `db_type` is replaced with timestamp with time zone either
- db_type: "timestamptz"
go_type: "time.Time"
Playground URL
https://play.sqlc.dev/p/2b3c34a2cbb6b39c97097dd41b5dba87ac45eeeae192be8e0e40e225405d6527
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go