Fixed #29338 -- Allowed using combined queryset in Subquery.

Thanks Eugene Kovalev for the initial patch, Simon Charette for the
review, and Chetan Khanna for help.
This commit is contained in:
Mariusz Felisiak 2022-01-17 18:01:07 +01:00 committed by GitHub
parent f37face331
commit 30a0144134
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 4 deletions

View file

@ -1048,6 +1048,12 @@ class Query(BaseExpression):
clone.bump_prefix(query)
clone.subquery = True
clone.where.resolve_expression(query, *args, **kwargs)
# Resolve combined queries.
if clone.combinator:
clone.combined_queries = tuple([
combined_query.resolve_expression(query, *args, **kwargs)
for combined_query in clone.combined_queries
])
for key, value in clone.annotations.items():
resolved = value.resolve_expression(query, *args, **kwargs)
if hasattr(resolved, 'external_aliases'):