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
Currently when doing a multiple join on the same table, fields or embedded structs are suffixed with the number of the join from which they come (see https://play.sqlc.dev/p/31f018cd6e834cd2ccd9122789cd91c8adf29e7ea5e478e6a29dfafd2846903e ).
Doing multiple joins on the same table results in first embed bearing the name of the original relation, the second one follows the pattern <relation_2>
It would be great if there was an option to allow the use of the alias instead of the numbered suffix (in the example above, the struct elements would become Location_b and Location_c respectively). I would assume such a change (if possible) would be quite a breaking change, so having it as an option defaulting to false might be better.
There are more reasons for this: if in the above example the joins would suddenly be reversed, the generated code would remain exactly the same even though the data contained by the Location and Location_2 would be changed, resulting in a quite insidious bug.
EDIT: the same could apply to fields themselves, to use the alias suffix instead of number.
What database engines need to be changed?
MySQL
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered:
andrei-dascalu
changed the title
Option to sufix embedded structs with alias name when available
Option to suffix embedded structs with alias name when available
Sep 8, 2023
What do you want to change?
Currently when doing a multiple join on the same table, fields or embedded structs are suffixed with the number of the join from which they come (see https://play.sqlc.dev/p/31f018cd6e834cd2ccd9122789cd91c8adf29e7ea5e478e6a29dfafd2846903e ).
Doing multiple joins on the same table results in first embed bearing the name of the original relation, the second one follows the pattern
<relation_2>
It would be great if there was an option to allow the use of the alias instead of the numbered suffix (in the example above, the struct elements would become
Location_b
andLocation_c
respectively). I would assume such a change (if possible) would be quite a breaking change, so having it as an option defaulting to false might be better.There are more reasons for this: if in the above example the joins would suddenly be reversed, the generated code would remain exactly the same even though the data contained by the
Location
andLocation_2
would be changed, resulting in a quite insidious bug.EDIT: the same could apply to fields themselves, to use the alias suffix instead of number.
What database engines need to be changed?
MySQL
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered: