Opened 8 months ago
Last modified 7 months ago
#35614 closed Bug
SQLCompiler.as_subquery_condition shouldn't modify the query object — at Version 1
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
.
Note:
See TracTickets
for help on using tickets.