Skip to content

Group by and left join using gives a "column reference is ambiguous #1425

Closed
@Yamakaky

Description

@Yamakaky

Version

1.12.0

What happened?

When using join ... using (key) group by key, sqlc seems to think key references the columns in the joined tables instead of the synthetic key column generated by using. where and having doesn't seem to have this problem, they work as expected.

This seem to be a regression since I have no problem with this kind of query in the 1.10.0 I use.

Relevant log output

sqlc generate failed.

# package db
query.sql:7:46: 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

select * from t1 join t2 using (fk) group by fk;

Configuration

No response

Playground URL

https://play.sqlc.dev/p/f9717de599d83359e7f1fdf15bbe7e3ed9cb57ce7c6b4c9dd6576a6445b140cd

What operating system are you using?

No response

What database engines are you using?

PostgreSQL

What type of code are you generating?

No response

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