#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-------------------------------------+-------------------------------------
     Reporter:  Matthieu Rigal       |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by David Sanders):

 There are a few ways to address this but IMHO I don't think anything
 should be done here as this is documented PostgreSQL behaviour [1]

 Therefore I'd recommend this ticket be marked `wontfix`.

 I think it's the developers responsibility to cast in this situation
 instead of using `ExpressionWrapper`:

 {{{
 next_segments = StartModel.objects.filter('start__gt':
 OuterRef('start')).order_by('start')
 qs = StartModel.objects.annotate(
             end=Cast(
                 Subquery(next_segments.values('start')[:1]) -
 datetime.timedelta(days=1),
                 output_field=DateField(),
             )
         )
 }}}


 [1] https://www.postgresql.org/docs/current/functions-datetime.html
 #OPERATORS-DATETIME-TABLE

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31506#comment:6>
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/0107018378b8abb5-e4257359-0d0c-46fc-ad65-875cf678de0a-000000%40eu-central-1.amazonses.com.

Reply via email to