-
Notifications
You must be signed in to change notification settings - Fork 888
Prepend table names to the generated enum names #716
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
Conversation
@@ -162,7 +163,7 @@ func (c *Catalog) createTable(stmt *ast.CreateTableStmt) error { | |||
} | |||
if col.Vals != nil { | |||
typeName := ast.TypeName{ | |||
Name: col.Colname, | |||
Name: fmt.Sprintf("%s_%s", stmt.Name.Name, col.Colname), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor annoyance with this is that it doesn't "singularize" the table's name.
It might also be frustrating to always opt-in to the longer enum names, when sometimes the terser names might suffice. But that seems trickier to fix
6818def
to
a57c517
Compare
I was going to say that this change is backwards incompatible, but this is the new MySQL implementation, so I'm okay making a breaking change. Not sure why you're test is failing, but I think this is overall a good change. |
Oh, hm. Well I'm all for avoiding backwards incompatible changes, but I think in this case it's more or less unavoidable? Right now the generated code will cause name collisions on the generated "enum" Go types; not sure how else to resolve that. That said, it might be worth spending more time deciding how the names should best be formed? E.g., if we want to get the de-pluralization to work, might be better to do it now than introduce another breaking change in the future? |
@kyleconroy Any thoughts on ^ ? If not, can fix the tests/go forward with this change. |
c817730
to
22607e5
Compare
I think this is fine as-is! Will merge once the tests have been updated and are passing. |
Otherwise we'll get a collision if a column name is shared for an enum table across two tables
22607e5
to
bb0cda5
Compare
Sounds good -- tests green now |
Thank you! |
Thanks for this one. Drove me crazy with databases where many tables had |
Otherwise we'll get a collision if a column name is shared for an enum column across two tables
This change is