﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35614	SQLCompiler.as_subquery_condition shouldn't modify the query object	Csirmaz Bendegúz	Csirmaz Bendegúz	"{{{SQLCompiler.as_subquery_condition}}} modifies the query object.

[https://github.com/django/django/blob/6b3f55446fdc62bd277903fd188a1781e4d92d29/django/db/models/sql/compiler.py#L1619 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}}}."	Bug	closed	Database layer (models, ORM)	5.0	Normal	fixed		Csirmaz Bendegúz	Ready for checkin	1	0	0	0	0	0
