[Django] #33391: Meaning of empty_result_set_value documentation

37 views
Skip to first unread message

Django

unread,
Dec 28, 2021, 2:35:21 PM12/28/21
to django-...@googlegroups.com
#33391: Meaning of empty_result_set_value documentation
------------------------------------------------+------------------------
Reporter: Claude Paroz | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
While translating the new docs, I struggled to understand the meaning of
this sentence about `Aggregate.empty_result_set_value`:

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?

https://docs.djangoproject.com/en/4.0/ref/models/expressions/#django.db.models.Aggregate.empty_result_set_value

--
Ticket URL: <https://code.djangoproject.com/ticket/33391>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 28, 2021, 3:41:25 PM12/28/21
to django-...@googlegroups.com
#33391: Meaning of empty_result_set_value documentation
-------------------------------------+-------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 4.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 30, 2021, 7:35:20 AM12/30/21
to django-...@googlegroups.com
#33391: Clarify Aggregate.empty_result_set_value docs.
--------------------------------------+------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* 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>

Django

unread,
Dec 30, 2021, 5:40:36 PM12/30/21
to django-...@googlegroups.com
#33391: Clarify Aggregate.empty_result_set_value docs.
--------------------------------------+------------------------------------
Reporter: Claude Paroz | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Claude Paroz):

* 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>

Django

unread,
Dec 30, 2021, 8:46:07 PM12/30/21
to django-...@googlegroups.com
#33391: Clarify Aggregate.empty_result_set_value docs.
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Mariusz
Type: | Felisiak
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* owner: nobody => Mariusz Felisiak
* status: new => assigned
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:4>

Django

unread,
Dec 31, 2021, 12:10:08 AM12/31/21
to django-...@googlegroups.com
#33391: Clarify Aggregate.empty_result_set_value docs.
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Mariusz
Type: | Felisiak
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 4.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

[https://github.com/django/django/pull/15263 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/33391#comment:5>

Django

unread,
Dec 31, 2021, 12:49:26 AM12/31/21
to django-...@googlegroups.com
#33391: Clarify Aggregate.empty_result_set_value docs.
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Mariusz
Type: | Felisiak
Cleanup/optimization | Status: closed
Component: Documentation | Version: 4.0
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* 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>

Django

unread,
Dec 31, 2021, 12:50:23 AM12/31/21
to django-...@googlegroups.com
#33391: Clarify Aggregate.empty_result_set_value docs.
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Mariusz
Type: | Felisiak
Cleanup/optimization | Status: closed
Component: Documentation | Version: 4.0

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages