[Django] #25487: Add support months and years in INTERVAL field of PosrgreSQL

7 views
Skip to first unread message

Django

unread,
Oct 1, 2015, 8:08:14 AM10/1/15
to django-...@googlegroups.com
#25487: Add support months and years in INTERVAL field of PosrgreSQL
----------------------------------+--------------------------------
Reporter: liminspace | Owner: liminspace
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Keywords: postgres, interval
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------
PostgeSQL supports months and years in INTERVAL field, but django doesn't
support it.
I propose add new field postgres.IntervalField that supports months and
years by using python-dateutil python library.

--
Ticket URL: <https://code.djangoproject.com/ticket/25487>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 1, 2015, 8:25:40 AM10/1/15
to django-...@googlegroups.com
#25487: Add support for months and years in INTERVAL field of PostgreSQL
------------------------------------+--------------------------------------

Reporter: liminspace | Owner: liminspace
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:

Keywords: postgres, interval | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by timgraham):

* cc: mjtamlyn (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

What's the reason `DurationField` doesn't support it? How soon do we
overflow the `bigint` storage of other database backends?

--
Ticket URL: <https://code.djangoproject.com/ticket/25487#comment:1>

Django

unread,
Oct 1, 2015, 12:07:24 PM10/1/15
to django-...@googlegroups.com
#25487: Add support for months and years in INTERVAL field of PostgreSQL
------------------------------------+--------------------------------------

Reporter: liminspace | Owner: liminspace
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:

Keywords: postgres, interval | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------

Comment (by liminspace):

Month is not a static value that you can convert to bigint.
See example:
TIMESTAMP '2001-02-02' + INTERVAL '1 month' = TIMESTAMP '2001-03-02'
TIMESTAMP '2001-02-02' + INTERVAL '31' days' = TIMESTAMP '2001-03-05'

--
Ticket URL: <https://code.djangoproject.com/ticket/25487#comment:2>

Django

unread,
Oct 1, 2015, 3:49:29 PM10/1/15
to django-...@googlegroups.com
#25487: Add support for months and years in INTERVAL field of PostgreSQL
------------------------------------+--------------------------------------

Reporter: liminspace | Owner: liminspace
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:

Keywords: postgres, interval | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------

Comment (by mjtamlyn):

Support for non-fixed durations is complicated - As liminspace mentioned
Python's timedelta does not support months or years (see
https://docs.python.org/3.2/library/datetime.html#datetime.timedelta).
Oracle actually has two completely separate fields for them, and the other
databases we could not store it in a single column either.

Also, what is the form field representation? How do we anticipate a user
will specify "2 months, 4 days and 1 hour" (in every language?), and will
they understand that 30 days != 1 month? In fact in postgres depending on
which functions you use to calculate age, you either get calendar months
or 30 day "months".

I think this should be possible as an external field for postgres and/or
Oracle, as it has external python dependencies as well it should live as
an external package. I'm not sure what psycopg2 does for month/year based
durations as normally it will try to cast `interval` to a `timedelta`.

--
Ticket URL: <https://code.djangoproject.com/ticket/25487#comment:3>

Django

unread,
Oct 2, 2015, 12:42:24 PM10/2/15
to django-...@googlegroups.com
#25487: Add support for months and years in INTERVAL field of PostgreSQL
------------------------------------+--------------------------------------
Reporter: liminspace | Owner: liminspace
Type: New feature | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: wontfix

Keywords: postgres, interval | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => wontfix


--
Ticket URL: <https://code.djangoproject.com/ticket/25487#comment:4>

Reply all
Reply to author
Forward
0 new messages