Opened 5 months ago
Closed 5 months ago
#35614 closed Bug (fixed)
SQLCompiler.as_subquery_condition shouldn't modify the query object
Reported by: | Csirmaz Bendegúz | Owned by: | Csirmaz Bendegúz |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Csirmaz Bendegúz | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
SQLCompiler.as_subquery_condition
modifies the query object.
django/db/models/sql/compiler.py#L1619
self.query.where.add(RawSQL("%s = %s" % (lhs_sql, rhs), lhs_params), AND)
This is unfortunate, because whenever the query is re-compiled, it adds another condition.
I noticed the issue when inspecting .query
on a queryset. Each time I accessed .query
, a new condition appeared.
An example queryset can be found in test MultiColumnFKTests.test_double_nested_query
.
Change History (5)
comment:1 by , 5 months ago
Description: | modified (diff) |
---|---|
Has patch: | set |
comment:2 by , 5 months ago
Easy pickings: | unset |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 5 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:4 by , 5 months ago
Note:
See TracTickets
for help on using tickets.
PR