Skip to content

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

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

Open
mispp opened this issue May 25, 2025 · 0 comments
Open

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

mispp opened this issue May 25, 2025 · 0 comments

Comments

@mispp
Copy link

mispp commented May 25, 2025

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 mispp added the bug Something isn't working label May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant