-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
Version
1.18.0
What happened?
There seems to be a minor bug in checking ambiguous references when joning tables while using alias.
To reproduce, change the sqlc/internal/endtoend/testdata/order_by_non_existing_column/postgresql to
-- Example queries for sqlc
CREATE TABLE authors (
id INT
);
CREATE TABLE books (
id INT,
author_id INT,
price INT
);
-- name: ListAuthors :many
SELECT id FROM authors
ORDER BY adfadsf;
-- name: ListAuthorsByCheapestBook :many
SELECT
author_id, min(b.price) as min_price
From books b inner join authors a on a.id = b.author_id
GROUP BY b.author_id
ORDER BY min_price;
The column of min_price is not ambiguous but sqlc reports:
# package
query.sql:13:1: column reference "adfadsf" not found: if you want to skip this validation, set 'strict_order_by' to false
query.sql:17:1: column reference "min_price" is ambiguous: if you want to skip this validation, set 'strict_order_by' to false
Relevant log output
query.sql:13:1: column reference "adfadsf" not found: if you want to skip this validation, set 'strict_order_by' to false
query.sql:17:1: column reference "min_price" is ambiguous: if you want to skip this validation, set 'strict_order_by' to falseDatabase schema
CREATE TABLE authors (
id INT
);
CREATE TABLE books (
id INT,
author_id INT,
price INT
);SQL queries
-- name: ListAuthorsByCheapestBook :many
SELECT
author_id, min(b.price) as min_price
From books b inner join authors a on a.id = b.author_id
GROUP BY b.author_id
ORDER BY min_price;Configuration
No response
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
Reactions are currently unavailable