Version
1.10.0
What happened?
When selecting with SELECT WITH with multiple table aliases in the FROM statement, only the last one on the statements list gets considered.
Given the query, we're expecting to select everything from both c1 and c2, but the generated query only selects from c2:
WITH
q
AS (
SELECT
authors.name, authors.bio
FROM
authors
LEFT JOIN fake ON authors.name = fake.name
)
SELECT
c2.name, c2.bio, c2.name, c2.bio
FROM
q AS c1,
q as c2
Relevant log output
No response
Database schema
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
CREATE TABLE fake (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
SQL queries
-- name: BadQuery :exec
WITH
q
AS (
SELECT
authors.name, authors.bio
FROM
authors
LEFT JOIN fake ON authors.name = fake.name
)
SELECT
*
FROM
q AS c1,
q as c2;
Configuration
{
"version": "1",
"packages": [
{
"path": "db",
"engine": "postgresql",
"schema": "query.sql",
"queries": "query.sql"
}
]
}
Playground URL
https://play.sqlc.dev/p/79910ee88639b38cdbcbbefeccb1e1a55b8492776ed7fd0a4bbb617217411d46
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
Version
1.10.0
What happened?
When selecting with
SELECT WITHwith multiple table aliases in the FROM statement, only the last one on the statements list gets considered.Given the query, we're expecting to select everything from both c1 and c2, but the generated query only selects from c2:
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/79910ee88639b38cdbcbbefeccb1e1a55b8492776ed7fd0a4bbb617217411d46
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go