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
{{ message }}
Repository navigation
Rename struct property name when using sqlc.embed in multiple joins from same table #3177
CREATETABLEtracks(
id SERIALPRIMARY KEY,
driver_id INTEGERNOT NULLREFERENCES persons(id),
recipient_id INTEGERNOT NULLREFERENCES persons(id)
);
CREATETABLEpersons(
id SERIALPRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255),
phone VARCHAR(255) NOT NULL,
created_at TIMESTAMPNOT NULL DEFAULT NOW(),
updated_at TIMESTAMPNOT NULL DEFAULT NOW()
);
SQL queries
SELECT*FROM tracks
LEFT JOIN persons as driver ONtracks.driver_id=driver.idLEFT JOIN persons as recipient ONtracks.recipient_id=recipient.idWHERE id = $1LIMIT1;
Activity
lcnlvrz commentedon Feb 4, 2024
By the moment the workaround that works for me is to create views and then use sqlc.embed
schema.sql
query.sql
ErikKalkoken commentedon Apr 14, 2024
The workaround is great, however it also leads to new types in the response struct, which makes it less useful in some cases.
e.g. the example would create something like this: