sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Duplicate struct members when using "like" and "inherits" in postgresql

Open mispp opened this issue 5 months ago • 0 comments

Version

1.29.0

What happened?

SQLC duplicates stuct data members when using inherits and like in the same create table statement.

For example

type LookupRiskType struct {
	Key    string      `json:"key"`
	Parent pgtype.Text `json:"parent"`
	Key    string      `json:"key"`
	Parent pgtype.Text `json:"parent"`
}

Relevant log output


Database schema

create table lookup (
    key text not null unique,
    parent text references lookup(key),

    primary key (key)
);

create table lookup_risk_type (like lookup including all) inherits (lookup);

SQL queries


Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "./query/"
    schema: "./migrations/"
    gen:
      go:
        emit_json_tags: true
        package: "sqlc"
        out: "sqlc"
        sql_package: "pgx/v5"
        overrides:
          - db_type: "uuid"
            go_type:
              import: "github.com/google/uuid"
              type: "UUID"
          - db_type: "timestamp with time zone"
            go_type:
              import: "time"
              type: "Time"
            nullable: true

Playground URL

https://play.sqlc.dev/p/1956e8df06564704f3935eec09c8056d8971faba77a3584682529e06cb1c1c39

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

mispp avatar May 25 '25 12:05 mispp