Open jmillerv opened 2 years ago
This is not an urgent issue as it doesn't hinder progress, I just thought it was a bit bizarre and wanted to flag it.
Also an issues with media
This one isn't a huge issue, I just have to remember to use the right name and to switch back when it's fixed. So in my migration schema, I have a couple structs that have media in them:
CREATE TABLE "name_media" (
"id" smallserial PRIMARY KEY
// other fields.
);
CREATE TABLE "another_name_media" (
"id" bigserial PRIMARY KEY
// other fields.
);
These are the generated structs:
type NameMedium struct {
ID int16 `json:"id"`
// other fields.
}
type AnotherNameMedium struct {
ID int64 `json:"id"`
// other fields.
}
I 'made' a playground for this, but realistically all I did was change authors to name_media and it happens. https://play.sqlc.dev/p/fe32fa791d8da82e238e014619ebfa9fefbfa3fa2bceaa363c2f40fdbba55b9b
You can actually fix this, but you have to know which key to use in the rename configuration. For bazaar.items_meta
the key is `bazaar_item_metum".
{
"version": "1",
"rename": {
"bazaar_items_metum": "BazaarItemsMeta",
},
"packages": [
{
"path": "db",
"engine": "postgresql",
"schema": "query.sql",
"queries": "query.sql"
}
]
}
https://play.sqlc.dev/p/c955263efe1a2f6b8ca8e1d040032caeccb181aaaad184d81907d3e66e9a72c2
You can also set the emit_exact_table_names option to true, but that applies to all tables.
Version
1.15.0
What happened?
I have a table called items_meta. When sqlc goes to make the struct the logic that attempts to make idiomatic go translates it to
type TableItemsMetum struct
. While this is usable that isn't, according to any reading I can find, an appropriate way to "singularize" that. Is sqlc applying the rules for data/datum to words that end ina
?This behavior also happens with the following words:
Database schema
SQL queries
No response
Configuration
Playground URL
https://play.sqlc.dev/p/66ae898df20d0347156df3f8bf842c3ed04709d5a9da5acf3aec9a229a2941db
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go