#30602: ExtractYear lookups on a DurationField fails
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
cecedille1 |
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 |
-------------------------------------+-------------------------------------
Lookups on ExtractYear on a DurationField fails because ExtractYear has an
optimisation where it compares the source date with a range of dates.
{{{
class MyModel(models.Model):
duration = models.DurationField()
MyModel.objects.annotate(year=ExtractYear('duration')).filter(year__gt=1)
}}}
The queryset generated looks like
{{{
SELECT * FROM mymodel WHERE duration > '0001-01-01'
}}}
and it fails because interval are not comparable with dates
--
Ticket URL: <https://code.djangoproject.com/ticket/30602>
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/053.b9c564865e352ff6ad9e3fa50b5b477c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.