-
Notifications
You must be signed in to change notification settings - Fork 900
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workingtriageNew issues that hasn't been reviewedNew issues that hasn't been reviewed
Description
Version
1.20.0
What happened?
When selecting *
from a subquery, the generated query selects all columns from all tables referenced in the subquery, not all fields selected by the subquery.
With the example provided below, the following query is generated:
SELECT t.id, authors.id, name, bio FROM (select id from authors) t
The generated query should be:
SELECT t.id FROM (select id from authors) t
If you modify the query to be:
SELECT t.* FROM (select id from authors) t;
then the generated query is correct.
Relevant log output
No response
Database schema
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
SQL queries
SELECT * FROM (select id from authors) t;
Configuration
{
"version": "1",
"packages": [
{
"path": "db",
"engine": "postgresql",
"schema": "query.sql",
"queries": "query.sql"
}
]
}
Playground URL
https://play.sqlc.dev/p/40aa4c5ab1bd5efb90024e9b35a08cdc83d28237ba2bfdc2f3ecf4ec47da4c68
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtriageNew issues that hasn't been reviewedNew issues that hasn't been reviewed