From bdd538488c837edec74cbfd4b0064228373319a1 Mon Sep 17 00:00:00 2001 From: Bendeguz Csirmaz Date: Thu, 18 Jul 2024 18:33:09 +0800 Subject: Fixed #35614 -- Prevented SQLCompiler.as_subquery_condition() from mutating a query. --- tests/foreign_object/tests.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/foreign_object') diff --git a/tests/foreign_object/tests.py b/tests/foreign_object/tests.py index c9e8da5792..2d3aa800f7 100644 --- a/tests/foreign_object/tests.py +++ b/tests/foreign_object/tests.py @@ -223,6 +223,13 @@ class MultiColumnFKTests(TestCase): [m2], ) + def test_query_does_not_mutate(self): + """ + Recompiling the same subquery doesn't mutate it. + """ + queryset = Friendship.objects.filter(to_friend__in=Person.objects.all()) + self.assertEqual(str(queryset.query), str(queryset.query)) + def test_select_related_foreignkey_forward_works(self): Membership.objects.create( membership_country=self.usa, person=self.bob, group=self.cia -- cgit v1.3