#34564: returning None instead of zero in Count annotation
-------------------------------------+-------------------------------------
Reporter: Amin Aminian | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: count, orm, | Triage Stage:
annotate | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* cc: Simon Charette (added)
Comment:
I think this should be considered a release blocker as this is an
unintended regression that will affect quite a few users given how common
count annotations are over multiple valued relationships.
Unlike `ArrayAgg` and friends in fee87345967b3d917b618533585076cbfa43451b
there was not deprecation period to force the usage of `default=0` for
`Count` in 9f3cce172f6913c5ac74272fa5fc07f847b4e112.
A simple solution for a backport would be to adjust `Count.__init__` to do
`extra.setdefault("default", 0)` (or define in it's signature for enhanced
introspection) so `Coalesce` is used.
Happy to submit a patch if you agree.
Amin, you can use `Count(..., default=0)` in the mean time.
--
Ticket URL: <https://code.djangoproject.com/ticket/34564#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018816b57371-b7befed0-35ac-4d84-ad29-c2c18b09dccb-000000%40eu-central-1.amazonses.com.