#24793: Subtracting DateTime fields in a query expression should use timediff
-------------------------------------+-------------------------------------
Reporter: sparkyb | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: datetime duration | Triage Stage: Accepted
expression |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by jarshwah):
Hi Lego,
I'm really sorry I've taken so long to get back to you, I'll do better in
future.
Where I think you should be looking is
django.db.models.expression.CombinedExpression.as_sql() method.
You would put some handling in there to check left and right hand side for
two dates, and then we'd probably have some backend specific SQL that
knows how to handle date(+-)date.
If you look in the as_sql method you'll see how DurationExpressions are
handled. It's guarded by a feature flag (has_native_duration_field). You
might want to guard by another feature flag, something like
"supports_date_arithmetic". You could then create a DateExpression class
that handles the backend specific way of doing date math.
Hopefully that's enough information for you to get started. Please hit me
up if you need some help or clarification.
--
Ticket URL: <https://code.djangoproject.com/ticket/24793#comment:3>
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/065.19c338adcd4e822c40d00c6b8333ff73%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.