-
Notifications
You must be signed in to change notification settings - Fork 900
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Version
1.25.0
What happened?
I just need to perform a query that joins multiple rows from same table and i expect sqlc to take alias from query when build final go structs
In current version when you join multiple times from same table, the final struct looks something like:
struct QueryOutput {
TableRow1 Table
TableRow2 Table
}
Relevant log output
No response
Database schema
CREATE TABLE tracks(
id SERIAL PRIMARY KEY,
driver_id INTEGER NOT NULL REFERENCES persons(id),
recipient_id INTEGER NOT NULL REFERENCES persons(id)
);
CREATE TABLE persons(
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255),
phone VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);
SQL queries
SELECT * FROM tracks
LEFT JOIN persons as driver ON tracks.driver_id = driver.id
LEFT JOIN persons as recipient ON tracks.recipient_id = recipient.id
WHERE id = $1 LIMIT 1;
Configuration
version: '2'
sql:
- engine: 'postgresql'
queries: 'query.sql'
schema: 'migrations'
gen:
go:
package: 'db'
out: 'db'
sql_package: 'pgx/v5'
emit_json_tags: true
emit_pointers_for_null_types: true
emit_all_enum_values: true
overrides:
- go_struct_tag: 'json:"-"'
column: '*.password'
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
ErikKalkoken, yuzuy, nwestbury, BrunoQuaresma, ilikeorangutans and 6 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working