sqlboiler
sqlboiler copied to clipboard
NO_TESTS env var ignore and field duplication
If you're having a generation problem please answer these questions before submitting your issue. Thanks!
What version of SQLBoiler are you using (sqlboiler --version)?
SQLBoiler v4.12.0
What is your database and version (eg. Postgresql 10)
mySQL 5.7.33
If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)
sqlboiler mysql
Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)
Will work on providing something relevant, if needed
Further information. What did you do, what did you expect?
I have encountered 2 issues:
- I've set environment variables (for db config prefixed with MYSQL), as follows
OUTPUT="src/models"
WIPE=true
NO_TESTS=true
ADD_ENUM_TYPES="true"
Although I've tried both with quotes and without quotes, NO_TESTS seems to be ignored all the time (all other config work as expected). Tests are always generated.
- For some entities, I get some strange field duplications:
var NewsletterSendResultColumns = struct {
ID string
NewsletterId string
ClientId string
Email string
NewsletterStatus string
ID string
RejectReason string
Timestamp string
}{
ID: "Id",
NewsletterId: "NewsletterId",
ClientId: "ClientId",
Email: "Email",
NewsletterStatus: "NewsletterStatus",
ID: "_id",
RejectReason: "Reject_Reason",
Timestamp: "Timestamp",
}
Ok, so there is a field called _id which technically is different and has a different name. I'm not sure if this a case that you'd considering handling differently, perhaps via some override parameters or some preset rules on handling potential conflicts. One such way would be to move the stripped character to a suffix (eg ID_ which is valid)
I'll check out the issue with the NO_TESTS env variable. In the meantime, perhaps you can add the flag --no-tests whenever you run the command.
For the _id field. Your best option will be to use an alias. In most cases, a table will not have both id and _id and it is better for the user experience if _id is just id. Ideally, SQLBoiler will check all other columns and maybe add the suffix instead of the duplication you are facing now.
Since this is a rare scenario that can easily be solved by adding an alias in your config, I doubt if we would change this behaviour.