summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorDavid Wobrock <david.wobrock@gmail.com>2021-09-24 22:05:02 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-29 20:52:59 +0200
commitaab76433ed585ebe997b94547e0d790605e01ad9 (patch)
tree48329f6a7adebfd0802120150f329d0aac7830d1 /django
parentcebac15931173b2fc5d8f2b3f4bd69fe1a8a856d (diff)
[4.0.x] Fixed #33141 -- Renamed Expression.empty_aggregate_value to empty_result_set_value.
Backport of ad36a198a12df4dff65992191b3eb0a474e2daac from main
Diffstat (limited to 'django')
-rw-r--r--django/contrib/postgres/aggregates/statistics.py2
-rw-r--r--django/db/models/aggregates.py6
-rw-r--r--django/db/models/expressions.py4
-rw-r--r--django/db/models/functions/comparison.py4
-rw-r--r--django/db/models/sql/query.py8
5 files changed, 12 insertions, 12 deletions
diff --git a/django/contrib/postgres/aggregates/statistics.py b/django/contrib/postgres/aggregates/statistics.py
index c0aae93bd3..2c83b78c0e 100644
--- a/django/contrib/postgres/aggregates/statistics.py
+++ b/django/contrib/postgres/aggregates/statistics.py
@@ -36,7 +36,7 @@ class RegrAvgY(StatAggregate):
class RegrCount(StatAggregate):
function = 'REGR_COUNT'
output_field = IntegerField()
- empty_aggregate_value = 0
+ empty_result_set_value = 0
class RegrIntercept(StatAggregate):
diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py
index 1ae4382784..596a161669 100644
--- a/django/db/models/aggregates.py
+++ b/django/db/models/aggregates.py
@@ -21,12 +21,12 @@ class Aggregate(Func):
filter_template = '%s FILTER (WHERE %%(filter)s)'
window_compatible = True
allow_distinct = False
- empty_aggregate_value = None
+ empty_result_set_value = None
def __init__(self, *expressions, distinct=False, filter=None, default=None, **extra):
if distinct and not self.allow_distinct:
raise TypeError("%s does not allow distinct." % self.__class__.__name__)
- if default is not None and self.empty_aggregate_value is not None:
+ if default is not None and self.empty_result_set_value is not None:
raise TypeError(f'{self.__class__.__name__} does not allow default.')
self.distinct = distinct
self.filter = filter
@@ -117,7 +117,7 @@ class Count(Aggregate):
name = 'Count'
output_field = IntegerField()
allow_distinct = True
- empty_aggregate_value = 0
+ empty_result_set_value = 0
def __init__(self, expression, filter=None, **extra):
if expression == '*':
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
index 9381257bb2..100da26ee6 100644
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -150,10 +150,10 @@ class Combinable:
class BaseExpression:
"""Base class for all query expressions."""
+ empty_result_set_value = NotImplemented
# aggregate specific fields
is_summary = False
_output_field_resolved_to_none = False
- empty_aggregate_value = NotImplemented
# Can the expression be used in a WHERE clause?
filterable = True
# Can the expression can be used as a source expression in Window?
@@ -797,7 +797,7 @@ class Value(SQLiteNumericMixin, Expression):
return fields.UUIDField()
@property
- def empty_aggregate_value(self):
+ def empty_result_set_value(self):
return self.value
diff --git a/django/db/models/functions/comparison.py b/django/db/models/functions/comparison.py
index 2dac47a0d2..e5882de9c2 100644
--- a/django/db/models/functions/comparison.py
+++ b/django/db/models/functions/comparison.py
@@ -66,9 +66,9 @@ class Coalesce(Func):
super().__init__(*expressions, **extra)
@property
- def empty_aggregate_value(self):
+ def empty_result_set_value(self):
for expression in self.get_source_expressions():
- result = expression.empty_aggregate_value
+ result = expression.empty_result_set_value
if result is NotImplemented or result is not None:
return result
return None
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 388c60545f..d1c0c333f5 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -487,11 +487,11 @@ class Query(BaseExpression):
self.default_cols = False
self.extra = {}
- empty_aggregate_result = [
- expression.empty_aggregate_value
+ empty_set_result = [
+ expression.empty_result_set_value
for expression in outer_query.annotation_select.values()
]
- elide_empty = not any(result is NotImplemented for result in empty_aggregate_result)
+ elide_empty = not any(result is NotImplemented for result in empty_set_result)
outer_query.clear_ordering(force=True)
outer_query.clear_limits()
outer_query.select_for_update = False
@@ -499,7 +499,7 @@ class Query(BaseExpression):
compiler = outer_query.get_compiler(using, elide_empty=elide_empty)
result = compiler.execute_sql(SINGLE)
if result is None:
- result = empty_aggregate_result
+ result = empty_set_result
converters = compiler.get_converters(outer_query.annotation_select.values())
result = next(compiler.apply_converters((result,), converters))