diff options
| author | Florian Hahn <flo@fhahn.com> | 2013-02-19 22:58:09 +0100 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-07-31 16:27:58 +0300 |
| commit | e888a9b30dd9d62a930b9244d1b5531bb17544b4 (patch) | |
| tree | 29e5a37b8690b6cfe55ac521feade20cdaaee478 /django/db/models/sql/query.py | |
| parent | e01b5a5823fa06a63382f87472978a16c77048d2 (diff) | |
Fixed #15624 -- Made sure aggregations are present in SELECT
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 9d4bb69d48..fa7ae51d9c 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -321,6 +321,7 @@ class Query(object): # information but retrieves only the first row. Aggregate # over the subquery instead. if self.group_by is not None: + from django.db.models.sql.subqueries import AggregateQuery query = AggregateQuery(self.model) @@ -996,6 +997,8 @@ class Query(object): field_name = field_list[0] source = opts.get_field(field_name) col = field_name + # We want to have the alias in SELECT clause even if mask is set. + self.append_aggregate_mask([alias]) # Add the aggregate to the query aggregate.add_to_query(self, alias, col=col, source=source, is_summary=is_summary) |
