Skip to content
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

sqlc not accepting go type overrides for timestamp with timezone on postgres #3815

Open
Kerod-Fresenbet-Gebremedhin2660 opened this issue Feb 1, 2025 · 0 comments
Labels

Comments

@Kerod-Fresenbet-Gebremedhin2660

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant