diff options
| author | Simon Charette <charette.s@gmail.com> | 2019-03-08 11:26:53 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-03-23 09:48:31 -0400 |
| commit | bdc07f176eb7c099ac3fdc42ebaadd48b7f67409 (patch) | |
| tree | b7377eb48c1f0fbdbfbf3992b2016ab26db74d73 /django | |
| parent | f19a4945e1191e1696f1ad8e6cdc6f939c702728 (diff) | |
Fixed #30188 -- Fixed a crash when aggregating over a subquery annotation.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/sql/query.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 4f2fe5acb5..74aed551a3 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -22,7 +22,7 @@ from django.db import DEFAULT_DB_ALIAS, NotSupportedError, connections from django.db.models.aggregates import Count from django.db.models.constants import LOOKUP_SEP from django.db.models.expressions import ( - BaseExpression, Col, F, OuterRef, Ref, SimpleCol, + BaseExpression, Col, F, OuterRef, Ref, SimpleCol, Subquery, ) from django.db.models.fields import Field from django.db.models.fields.related_lookups import MultiColSource @@ -382,7 +382,7 @@ class Query(BaseExpression): # before the contains_aggregate/is_summary condition below. new_expr, col_cnt = self.rewrite_cols(expr, col_cnt) new_exprs.append(new_expr) - elif isinstance(expr, Col) or (expr.contains_aggregate and not expr.is_summary): + elif isinstance(expr, (Col, Subquery)) or (expr.contains_aggregate and not expr.is_summary): # Reference to column. Make sure the referenced column # is selected. col_cnt += 1 |
