From d79fba7d8e7bbcdf53535a14d57ead5a6863cd8d Mon Sep 17 00:00:00 2001 From: Hisham Mahmood Date: Tue, 6 Feb 2024 19:40:01 +0500 Subject: Fixed #35099 -- Prevented mutating queryset when combining with & and | operators. Thanks Alan for the report. Co-authored-by: Mariusz Felisiak --- django/db/models/sql/query.py | 1 + 1 file changed, 1 insertion(+) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 5100869b34..b3f130c0b4 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -696,6 +696,7 @@ class Query(BaseExpression): # except if the alias is the base table since it must be present in the # query on both sides. initial_alias = self.get_initial_alias() + rhs = rhs.clone() rhs.bump_prefix(self, exclude={initial_alias}) # Work out how to relabel the rhs aliases, if necessary. -- cgit v1.3