#25937: Failure when using expressions.DateTime on NULL values and aggregating
-------------------------------------+-------------------------------------
Reporter: Thomas Recouvreux | Owner: Cheryl
| Yang
Type: Bug | Status: assigned
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Normal | Resolution:
Keywords: aggregate timezone | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Aaron McMillin):
Here's a possible workaround for the failing case:
{{{
Potato.objects.annotate(
time=Coalesce(
DateTime('removed', 'month', timezone.UTC()),
Value(datetime.min),
).values('time').annotate(c=Count('pk'))
}}}
This replaces the NULL times with an easy to spot sentinel. if you were
already using `datetime.min`, you'll have to come up with something else.
--
Ticket URL: <https://code.djangoproject.com/ticket/25937#comment:10>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.ef315b95e03b2fa202bdca27c2fc4430%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.