Skip to content

Not null Timestamp/Timestamptz fields are not casted to time.Time by default #2932

Closed as not planned
@okanmete

Description

@okanmete

Version

1.23.0

What happened?

Hi, Recently, I upgraded my "pgx" version from v4 to v5. I was using sqlc v1.17.2 and also upgraded it to v1.23.0 . My problem is in pgx4, the "not null timestamptz/timestamp" types are generated as time.Time and nullable ones are generated as sqlNullTime as expected. However, after I switch to pgx5, regardles of a timestamptz/timestamp field is null or not-null, the golang object is always generated as pgType.Timestamp, pgType.Timestamptz.

Indeed, when I apply the below overrides in my sqlc.yaml file, the problem is resolved and nullable types are generated as pgType.Timestamptz, not null types are generated as time.Time as expected. My question is, should not it be something happening by default ?

    overrides:
      - db_type: "pg_catalog.timestamp"
        go_type:
          type: "Time"
          import: "time"
      - db_type: "timestamp"
        go_type:
          type: "Time"
          import: "time"
      - db_type: "pg_catalog.timestamptz"
        go_type:
          type: "Time"
          import: "time"
      - db_type: "timestamptz"
        go_type:
          type: "Time"
          import: "time"

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions