#34564: returning None instead of zero in Count annotation
-------------------------------------+-------------------------------------
Reporter: Amin Aminian | Owner: Amin
| Aminian
Type: Bug | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: count, orm, | Triage Stage: Accepted
annotate |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Amin Aminian):
Hi again.
I implemented the first solution, I want to just double check the output
...
I removed `empty_result_set_value` class attr from both `Count` and
`RegrCount`, so basically they are inheriting this attr from `Aggregate`
class.
In `__init__` method of `Count` and `RegrCount` class, I called
`super()...` with `default=0`, so the default value is 0 for `Count`. But
still, I don't let user pass default value for `Count` and the default
value would be 0 all the time.
So basically `Coalesce` is appended to `Count` query with this default
value. I fixed all tests that had `SELECT COUNT(...)` and changed it to
`SELECT COALESCE(COUNT(...), 0)`.
Is everything right and as we wanted ?
Thanks for your time Simon!
--
Ticket URL: <https://code.djangoproject.com/ticket/34564#comment:12>
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/01070188380c3c5e-aaeb83b0-2ddf-4f88-ac1e-aba81cc89e66-000000%40eu-central-1.amazonses.com.