mirror of
https://github.com/django/django.git
synced 2025-08-23 20:14:17 +00:00
Fixed #27862 -- Fixed incorrectly quoted table aliases in Subquery SQL.
Add aliases from resolved querysets to the parent query's external aliases to prevent those aliases from being quoted. Thanks to Vasily Stepanov for the report and Tim Graham for the review.
This commit is contained in:
parent
9f21e35100
commit
f48bc7c3db
2 changed files with 15 additions and 1 deletions
|
@ -940,10 +940,15 @@ class Subquery(Expression):
|
|||
|
||||
def resolve(child):
|
||||
if hasattr(child, 'resolve_expression'):
|
||||
return child.resolve_expression(
|
||||
resolved = child.resolve_expression(
|
||||
query=query, allow_joins=allow_joins, reuse=reuse,
|
||||
summarize=summarize, for_save=for_save,
|
||||
)
|
||||
# Add table alias to the parent query's aliases to prevent
|
||||
# quoting.
|
||||
if hasattr(resolved, 'alias'):
|
||||
clone.queryset.query.external_aliases.add(resolved.alias)
|
||||
return resolved
|
||||
return child
|
||||
|
||||
resolve_all(clone.queryset.query.where)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue