Override empty_result_set_value to None since most aggregate functions
result in NULL when applied to an empty result set.
It's totally possible my limited English prevents me understanding this,
in that case, maybe someone may explains that to me?
--
Ticket URL: <https://code.djangoproject.com/ticket/33391>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Tim Graham):
Looking at 9f3cce172f6913c5ac74272fa5fc07f847b4e112 where it was
introduced, the language seems to resemble a code comment explaining why
`Aggregate_aggregate_value` is set to `None`. It's unclear to me if this
information is useful to Django users. At the least, it seems a rephrasing
is appropriate ("Override" to "Overrides", perhaps).
--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:1>
* stage: Unreviewed => Accepted
Comment:
`Aggregate.empty_result_set_value` defaults to `None` which is fine for
most (all?) aggregates, so I'd clarify this in docs, e.g.:
{{{#!diff
diff --git a/docs/ref/models/expressions.txt
b/docs/ref/models/expressions.txt
index 5ea7f9f0aa..208b810048 100644
--- a/docs/ref/models/expressions.txt
+++ b/docs/ref/models/expressions.txt
@@ -418,9 +418,8 @@ The ``Aggregate`` API is as follows:
.. versionadded:: 4.0
- Override
:attr:`~django.db.models.Expression.empty_result_set_value` to
- ``None`` since most aggregate functions result in ``NULL`` when
applied
- to an empty result set.
+ Defaults to ``None`` since most aggregate functions result in
``NULL``
+ when applied to an empty result set.
The ``expressions`` positional arguments can include expressions,
transforms of
the model field, or the names of model fields. They will be converted to
a
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:2>
* has_patch: 0 => 1
Comment:
Ah thanks, now I understand (even the original sentence!). The new
proposal is a lot better!
--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:3>
* owner: nobody => Mariusz Felisiak
* status: new => assigned
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:4>
Comment (by Mariusz Felisiak):
[https://github.com/django/django/pull/15263 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"4400d8568ad5695c46e8de45635a82a27a26b871" 4400d856]:
{{{
#!CommitTicketReference repository=""
revision="4400d8568ad5695c46e8de45635a82a27a26b871"
Fixed #33391 -- Clarified Aggregate.empty_result_set_value docs.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"fe59bf202d35467e3e4a169c1aac979b713a020a" fe59bf2]:
{{{
#!CommitTicketReference repository=""
revision="fe59bf202d35467e3e4a169c1aac979b713a020a"
[4.0.x] Fixed #33391 -- Clarified Aggregate.empty_result_set_value docs.
Backport of 4400d8568ad5695c46e8de45635a82a27a26b871 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:7>