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

Postgresql column ambiguity with using clause #3662

Open
prog8 opened this issue Oct 18, 2024 · 0 comments
Open

Postgresql column ambiguity with using clause #3662

prog8 opened this issue Oct 18, 2024 · 0 comments
Labels

Comments

@prog8
Copy link

prog8 commented Oct 18, 2024

Version

1.27.0

What happened?

Postgres docs says USING clause makes redundant column suppressions.

Furthermore, the output of JOIN USING suppresses redundant columns: there is no need to print both of the matched columns, since they must have equal values. While JOIN ON produces all columns from T1 followed by all columns from T2, JOIN USING produces one output column for each of the listed column pairs (in the listed order), followed by any remaining columns from T1, followed by any remaining columns from

Unfortunately sqlc finds redundant column name ambiguous

Relevant log output

column reference "fk" is ambiguous

Database schema

create table t1 (
        fk integer not null unique
);
create table t2 (
        fk integer not null references t1(fk)
);

SQL queries

-- name: SelectJoinUsing :many
select fk, sum(t2.fk) from t1 join t2 using (fk) group by fk;

Configuration

version: "2"
sql:
  - engine: "postgresql"
    schema: "schema.sql"
    queries: "query.sql"
    gen:
      go:
        package: "querytest"
        out: "go"
        sql_package: "pgx/v5"

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@prog8 prog8 added the bug Something isn't working label Oct 18, 2024
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