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
[Question] How to differentiate between fields of the same name coming from different tables in a JOIN ? #2710
-- name: FindAccountById :oneSELECT*FROM`Account` a
LEFT JOIN`Address` adMain ONa.MainAddressId=adMain.IdLEFT JOIN`Address` adAlt ONa.AlternateAddressId=adAlt.IdWHEREa.Id= ?;
when generating the code (mysql driver), the generated method FindAccountById will be returning a custom FindAccountByIdRow where the Id fields coming from different tables are named like Id, Id_2 and Id_3.
I'm not sure if there's something that can be currently done to easily differentiate or have the generated code use table aliases to tell the tables apart (so that the resulting struct elements would be called AdMain_Id and AdAlt_Id respectively . Is there something that can be done to easily manage this situation? Could this be an improvement? Is this something that's more related to the mysql driver than sqlc?
EDIT:
rename:
spotify_url: "SpotifyURL"
doesn't seem useful in this case. The name of the resulting struct field depends on context (eg: every table may have an ID, but whether it ends up being Id_2 or Id_3 depends on the exact query and what joins happen).
Activity