summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 2c6a50934d..73c9e5ca4f 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -634,6 +634,10 @@ class Query(BaseExpression):
joinpromoter.add_votes(rhs_votes)
joinpromoter.update_join_types(self)
+ # Combine subqueries aliases to ensure aliases relabelling properly
+ # handle subqueries when combining where and select clauses.
+ self.subq_aliases |= rhs.subq_aliases
+
# Now relabel a copy of the rhs where-clause and add it to the current
# one.
w = rhs.where.clone()