mirror of
https://github.com/django/django.git
synced 2025-11-27 13:55:26 +00:00
Fixed #33282 -- Fixed a crash when OR'ing subquery and aggregation lookups.
As a QuerySet resolves to Query the outer column references grouping logic should be defined on the latter and proxied from Subquery for the cases where get_group_by_cols is called on unresolved expressions. Thanks Antonio Terceiro for the report and initial patch.
This commit is contained in:
parent
e3bde71676
commit
e5a92d400a
3 changed files with 43 additions and 8 deletions
|
|
@ -1053,6 +1053,14 @@ class Query(BaseExpression):
|
|||
if col.alias in self.external_aliases
|
||||
]
|
||||
|
||||
def get_group_by_cols(self, alias=None):
|
||||
if alias:
|
||||
return [Ref(alias, self)]
|
||||
external_cols = self.get_external_cols()
|
||||
if any(col.possibly_multivalued for col in external_cols):
|
||||
return [self]
|
||||
return external_cols
|
||||
|
||||
def as_sql(self, compiler, connection):
|
||||
# Some backends (e.g. Oracle) raise an error when a subquery contains
|
||||
# unnecessary ORDER BY clause.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue