You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
When executing a SQL query that JOINs the same table multiple times with different aliases, SQLC generates Go structs with numbered field suffixes (e.g., Company_2, Company_3) instead of using the specified aliases. This occurs even when using explicit table aliases in the query.
Reproduction Steps:
Create a SQL query with multiple joins to the same table:
-- name: GetProjectDetails :oneSELECT
p.*,
sqlc.embed(m) AS manager_company,
sqlc.embed(c) AS client_company,
sqlc.embed(v) AS vendor_company
FROM projects p
LEFT JOIN companies m ONp.manager_id=m.id-- Manager companyLEFT JOIN companies c ONp.client_id=c.id-- Client companyLEFT JOIN companies v ONp.vendor_id=v.id-- Vendor companyWHEREp.id= $1;
Run sqlc generate
Actual Behavior:
Generated Go struct contains numbered fields:
Version
1.28.0
What happened?
Description:
When executing a SQL query that JOINs the same table multiple times with different aliases, SQLC generates Go structs with numbered field suffixes (e.g., Company_2, Company_3) instead of using the specified aliases. This occurs even when using explicit table aliases in the query.
Reproduction Steps:
Create a SQL query with multiple joins to the same table:
Run sqlc generate
Actual Behavior:
Generated Go struct contains numbered fields:
Expected Behavior:
Struct fields should respect SQL aliases:
Relevant log output
Database schema
SQL queries
Configuration
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
The text was updated successfully, but these errors were encountered: