#24485: Support for annotate(end=F('start') + F('duration'),
output_field=DateTimeField)
-------------------------------------+-------------------------------------
     Reporter:  yoyoma               |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  durationfield,       |             Triage Stage:
  aggregation, annotation            |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by jarshwah):

 What would you expect the SQL output of SUM(date_field) to be? Most
 databases (all?) do not allow Sum(date). The argument to Sum has to be
 numeric or convertable to numeric. Sum(interval) works for some backends.

 What I suspect you really want though is this:

 {{{
 Ticket.objects.annotate(
     expires_at=(F('active_at') + F('duration'),
 output_field=models.DateTimeField())
 )
 }}}

 Note that I've removed the Sum. We're now just adding two fields. I'm not
 100% sure that this is supported on all backends, but if it's not it
 should be. Also note that I've wrapped both F() expressions in brackets so
 that I can apply the output_field to the combination of both. Can you give
 that a go and report back please?

--
Ticket URL: <https://code.djangoproject.com/ticket/24485#comment:2>
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/064.dcd93912153eea979bb9041736b8e2c1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to