Closed
Description
Version
1.19.1
What happened?
Discovered while working on #2537, sqlc returns an ambiguous column reference error for some queries which run fine with psql. See examples below.
To fix we'll need to update findColumnForRef()
in output_columns.go
I believe.
Relevant log output
query.sql:9:1: column reference "name" is ambiguous: if you want to skip this validation, set 'strict_order_by' to false
Database schema
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
SQL queries
SELECT a.name
FROM authors a JOIN authors b ON a.id = b.id
ORDER BY name;
SELECT a.name AS name
FROM authors a JOIN authors b ON a.id = b.id
ORDER BY name;
Configuration
{
"version": "1",
"packages": [
{
"path": "db",
"engine": "postgresql",
"schema": "query.sql",
"queries": "query.sql"
}
]
}
Playground URL
https://play.sqlc.dev/p/8e9c3fa8f50201433c489b118a731130a7011574ec53d27bbe460eb1978f2f13
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go