diff options
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/query.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 8a4f88a9c8..12a3705674 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -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): |
