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
When using mysql as the engine, the table and column names are normalized to lowercase, losing useful naming conventions from the database. It's a very postgres specific thing that table and column names should be lowercase. But in Mysql this limitation does not exist.
e.g. a column called KapNr will become Kapnr in the generated struct. If I then marshal that into a JSON, even with JSON tags in camelCase it will just become kapnr instead of kapNr.
We can use the rename configuration, but then that configuration is ignored for generating the json tag, so it is still only half a workaround.
For context (feel free to skip), to keep my code simple, the way I name my columns in a database, structs and output JSON are usually as similar as possible. The less mapping from 1 format to another, the better. However, now I am forced to put extra mappings in between with custom structs to fix this.
Version
1.24.0
What happened?
When using
mysql
as the engine, the table and column names are normalized to lowercase, losing useful naming conventions from the database. It's a very postgres specific thing that table and column names should be lowercase. But in Mysql this limitation does not exist.e.g. a column called
KapNr
will becomeKapnr
in the generated struct. If I then marshal that into a JSON, even with JSON tags in camelCase it will just becomekapnr
instead ofkapNr
.We can use the
rename
configuration, but then that configuration is ignored for generating the json tag, so it is still only half a workaround.For context (feel free to skip), to keep my code simple, the way I name my columns in a database, structs and output JSON are usually as similar as possible. The less mapping from 1 format to another, the better. However, now I am forced to put extra mappings in between with custom structs to fix this.
Relevant log output
No response
Database schema
SQL queries
No response
Configuration
Playground URL
https://play.sqlc.dev/p/28279d28759d2a8d64af19286ee73de6c27b7003d0caa821d0e311652cf01a17
What operating system are you using?
Linux
What database engines are you using?
MySQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: