Skip to content

type override works partly #4050

@ip75

Description

@ip75

Version

1.29.0

What happened?

I have the same issue in v1.29.0
override don't work at all

config:

version: "2"
overrides:
  go:
    overrides:
      - db_type: "bigserial"
        go_type: "uint"
      - db_type: "bigint"
        go_type: "int"
      - db_type: "serial"
        go_type: "int"
      - db_type: "integer"
        go_type: "int"
      - db_type: "timestamptz"
        nullable: true
        go_type:
          type: "time.Time"
          pointer: true
      - db_type: "timestamptz"
        nullable: false
        go_type:
          type: "time.Time"
          pointer: false
      - db_type: "timestamp"
        nullable: true
        go_type:
          type: "time.Time"
          pointer: true
      - db_type: "timestamp"
        nullable: false
        go_type:
          type: "time.Time"
          pointer: false

result:

type TgConfig struct {
	GroupID int64 `json:"group_id"`
....
	RecentUpdateTime pgtype.Timestamp `json:"recent_update_time"`
}

int64 has to be int
pgtype.Timestamp has to be time.Time

#3751 closed but is not resolved
#3712 is not related

Relevant log output

Database schema

create table tg_topics (
    id bigserial primary key,
    message_thread_id bigint not null,
    tag_id integer references tag(id) not null,
    name text unique not null,
    icon_custom_emoji_id integer,
    created timestamp default NULL,
    CONSTRAINT tg_unique_topic UNIQUE(message_thread_id, tag_id)
);

-- config for sending messages
create table tg_config (
    id bigserial primary key,
    token text not null,
    group_id bigint not null, -- chat_id
    media_path text not null,
    assets_path text not null,
    recent_update_time timestamp default null  -- last time updated topics for telegram, updated when recent audio sent to topic.
);

CREATE TABLE public.tag (
	id serial4 NOT NULL,
	"name" varchar(128) NOT NULL,
	CONSTRAINT tag_name_key UNIQUE (name),
	CONSTRAINT tag_pkey PRIMARY KEY (id)
);
CREATE INDEX tag_name_idx ON public.tag USING btree (name);

SQL queries

-- name: ListAllTopics :many
select * from tg_topics;

Configuration

version: "2"
overrides:
  go:
    overrides:
      - db_type: "bigserial"
        go_type: "uint"
      - db_type: "bigint"
        go_type: "int"
      - db_type: "serial"
        go_type: "int"
      - db_type: "integer"
        go_type: "int"
      - db_type: "timestamptz"
        nullable: true
        go_type:
          type: "time.Time"
          pointer: true
      - db_type: "timestamptz"
        nullable: false
        go_type:
          type: "time.Time"
          pointer: false
      - db_type: "timestamp"
        nullable: true
        go_type:
          type: "time.Time"
          pointer: true
      - db_type: "timestamp"
        nullable: false
        go_type:
          type: "time.Time"
          pointer: false

sql:
  - engine: "postgresql"
    queries: "queries.sql"
    schema: "../schema/tg.sql"
    gen:
      go:
        package: "gen"
        out: "gen"
        sql_package: "pgx/v5"

Playground URL

look at the timestamp

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions