Open menma1234 opened 1 year ago
At the moment, SQLBoiler's query building can be used to generate invalid queries. There is nothing stopping a user from using qm.InnerJoin()
in a DELETE query which is technically wrong.
There are some ideas around overhauling the query system, but if it introduces a breaking change, then it will have to happen with the next major version.
If you have any ideas and can send in a PR, I'll be happy to review.
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.13.0
What is your database and version (eg. Postgresql 10)
Postgres 10
If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)
N/A
If this happened at runtime what code produced the issue? (if not applicable leave blank)
Output:
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)N/A
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?
With a many-to-many relationship, we wanted to remove all of the relationships between the two tables (i.e. remove all entries from the bridge table where the ID matches the first type's ID). Instinctively, I tried using
first.Seconds().DeleteAll()
but this appears to try to delete all records from thesecond
table though theWHERE
clause is wrong and gives aWHERE
clause containing the bridge table's name, causing a SQL error.Our workaround is currently to call
first.SetSeconds()
with an empty list, but it feels like something should be done about the first attempted usage (whether it's removingDeleteAll
from this scenario or fixing it to do the right thing) since it generates invalid SQL.