Skip to content

Option to suffix embedded structs with alias name when available #2719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrei-dascalu opened this issue Sep 8, 2023 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@andrei-dascalu
Copy link

andrei-dascalu commented 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 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

@andrei-dascalu andrei-dascalu added enhancement New feature or request triage New issues that hasn't been reviewed labels Sep 8, 2023
@andrei-dascalu 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
@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Sep 13, 2023
@kyleconroy
Copy link
Collaborator

Closing as a duplicate of #2686

@kyleconroy kyleconroy closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants