#31446: Annotate with ExpressionWrapper gives wrong result on date field
-------------------------------------+-------------------------------------
Reporter: Gerben | Owner: nobody
Morsink |
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
from django.db.models import DateTimeField, ExpressionWrapper, F
When doing:
Ticket.objects.annotate(
notify_date=ExpressionWrapper(
F('date') - F('notify_before_in_days'), output_field=DateField()))
With on Ticket a modelfield: date = models.DateField() will yield wrong
results if notify_before_in_days passes through the month boundary.
E.g. If date is 9th of April and notify_before_in_days = 10, it will
yield: 20200399 for notify_date, instead of 20200331.
Database is MySQL 8.0.19-0ubuntu0.19.10.3 - (Ubuntu), Django version is
2.2.10.
--
Ticket URL: <https://code.djangoproject.com/ticket/31446>
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/049.b67c0353702ec441e120e192e744bc06%40djangoproject.com.