#2443: Add IntervalField to database models -------------------------------------+------------------------------------- Reporter: ben.tucker@… | Owner: mjtamlyn Type: New feature | Status: assigned Component: Database layer | Version: master (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: IntervalField | Needs documentation: 0 interval duration DurationField | Patch needs improvement: 1 feature | UI/UX: 1 Has patch: 1 | Needs tests: 0 | Easy pickings: 0 | -------------------------------------+------------------------------------- Changes (by akaariai):
* needs_better_patch: 0 => 1 Comment: I think we need support for `qs.filter(event_startdate__gte=datetime.now() - F('event_duration))`. I think this works on PostgreSQL, but at least on Oracle it produces wrong results. The event_duration is in microseconds, but in oracle the date arithmetic interprets integers as days. Actually, I am not sure if this query works at all. In any case usages of F('duration_field') need tests. Raising errors from F() usage is acceptable, but producing wrong results is clearly not OK. Another issue that keeps nagging me is the use of SubfieldBase to support value conversion (SubfieldBase basically calls to_python() anytime the field is set on the object). Other fields in Django core do not use this, instead they let the backend convert the values. I am not sure if usage of SubfieldBase leads to any problems, but I keep getting the feeling we should be consistent in not using SubfieldBase. One case where usage of backend specific converters differ from usage of to_python + SubfieldBase is that SubfieldBase does value conversions on assignment. So: {{{ >>> obj.duration_field = '12:34:56' >>> obj.duration_field OUT: '12:34:56' if not using SubfieldBase OUT: timedelta(12h, 34m, 56s) }}} Currently no local field in Django core do value conversions on assignment. In addition there is clear overhead in model `__init__` when using SubfieldBase, I'd guess the overhead is somewhere around 20% per field that uses SubfieldBase, though I haven't benchmarked this. -- Ticket URL: <https://code.djangoproject.com/ticket/2443#comment:60> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/078.2f0918c6523159f6957881b2907cd739%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.