mirror of
https://github.com/django/django.git
synced 2025-12-03 00:26:25 +00:00
Fixed #15624 -- Made sure aggregations are present in SELECT
This commit is contained in:
parent
e01b5a5823
commit
e888a9b30d
3 changed files with 10 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue