1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Fixed #10089 -- Corrected handling of aggregates when the query set contains no items (and the cursor returns None). Thanks to Kyle Fox for the report, and david for the initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9786 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2009-01-23 11:03:48 +00:00
parent ed3d2735a2
commit 0e15932be3
5 changed files with 35 additions and 3 deletions

View File

@@ -217,6 +217,8 @@ class BaseQuery(object):
to return Decimal and long types when they are not needed.
"""
if value is None:
if aggregate.is_ordinal:
return 0
# Return None as-is
return value
elif aggregate.is_ordinal:
@@ -295,10 +297,14 @@ class BaseQuery(object):
query.related_select_cols = []
query.related_select_fields = []
result = query.execute_sql(SINGLE)
if result is None:
result = [None for q in query.aggregate_select.items()]
return dict([
(alias, self.resolve_aggregate(val, aggregate))
for (alias, aggregate), val
in zip(query.aggregate_select.items(), query.execute_sql(SINGLE))
in zip(query.aggregate_select.items(), result)
])
def get_count(self):