Closed kelzenberg closed 1 month ago
I tried aliasing the problematic table but I see no change in the generated models.
[aliases.tables]
BmElementColumn = "BmElementColumnAlias"
and
[aliases.tables.BmElementColumn]
up_plural = "BmElementColumnsA"
up_singular = "BmElementColumn"
down_plural = "bmElementColumnsA"
down_singular = "bmElementColumn"
Then I tried changing the way plural wording is created, also no change.
[inflections.plural_exact]
column = "columnsAll"
The TableNames
struct in boil_table_names.go
also continues to hold the BmElementColumn
name. Both aliases and inflections do not change anything in the generated output. It also does not appear in the --debug
output.
Unfortunately the documentation is not very clear in respect of how MSSQL table names are affected. What am I missing here?
Adding this to the config file:
[aliases.tables.BmElementColumn]
up_plural = "BmElementColumnsFoo"
up_singular = "BmElementColumnFoo"
down_plural = "bmElementColumnsFoo"
down_singular = "bmElementColumnFoo"
Lists this in the JSON debug output:
"config": {
"aliases": {
"tables": {
"BmElementColumn": {
"up_plural": "BmElementColumns",
"up_singular": "BmElementColumn",
"down_plural": "bmElementColumns",
"down_singular": "bmElementColumn",
"columns": [...],
}
...
"bmelementcolumn": {
"up_plural": "BmElementColumnsFoo",
"up_singular": "BmElementColumnFoo",
"down_plural": "bmElementColumnsFoo",
"down_singular": "bmElementColumnFoo"
}
}
}
}
Clearly the case-sensitivity is the culprit here. The part with
challenged by viper lowercasing all of your keys
makes sense now. The proposed solution...
[[aliases.tables]]
name = "BmElementColumn"
up_plural = "BmElementColumnsFoo"
up_singular = "BmElementColumnFoo"
down_plural = "bmElementColumnsFoo"
down_singular = "bmElementColumnFoo"
...was initially problematic but seems to work for now. Issue can be closed. What a journey...
Generated model files redeclare variables from other generated model files because the table name finishes with the word "column". Then tests will fail with:
More info below.
What version of SQLBoiler are you using (
sqlboiler --version
)?SQLBoiler v4.16.2
What is your database and version (eg. Postgresql 10)
Microsoft SQL Server 16.0.1000
If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)
sqlboiler mssql
go test ./models
If this happened at runtime what code produced the issue? (if not applicable leave blank)
What is the output of the command above with the
-d
flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)
Further information. What did you do, what did you expect?
sqlboiler.toml
Among other tables in the mssql database, I have two tables
BmElement
andBmElementColumn
(and I can't edit the schema).sqlboiler mssql
var BmElementColumns = struct{}
as static constants for column names for the BmElement tablefunc BmElementColumns(mods ...qm.QueryMod) bmElementColumnQuery {}
function to retrieve all records using an executor for the BmElementColumn tableAs you can see the table naming interferes with the generated suffixes of table functions and variables. I tried to use aliases and inflection (see comment below).