[Django] #36045: Add Support for PostgreSQL Infinity and -Infinity in Date/Time Fields

12 views
Skip to first unread message

Django

unread,
Dec 30, 2024, 8:27:11 AM12/30/24
to django-...@googlegroups.com
#36045: Add Support for PostgreSQL Infinity and -Infinity in Date/Time Fields
-------------------------------------+-------------------------------------
Reporter: Kavin Bharathi | Type: New
| feature
Status: new | Component: Database
| layer (models, ORM)
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
**Proposed Feature:**

1. Add support for parsing PostgreSQL's infinity and -infinity values into
Django models.
2. Represent infinity and -infinity using custom Python objects or
constants (e.g., django.db.utils.Infinity and -Infinity).
3. Ensure seamless integration with Django's ORM for querying, inserting,
and updating fields containing these values.
4. Provide a mechanism to serialize and deserialize these values (e.g.,
JSON serialization).

**Use Cases:**

1. Handling open-ended event durations.
2. Representing date ranges without a start or end boundary.
3. Supporting applications that already use these values in their
PostgreSQL databases.

**Benefits:**

1. Enables Django developers to work with PostgreSQL databases more
effectively.
2. Expands Django's compatibility with PostgreSQL's advanced features.

**Potential Challenges:**

1. Ensuring backward compatibility with existing applications.
2. Deciding on a Python representation for infinity that integrates well
with Django's ORM and other Python libraries.

**References:**

[PostgreSQL Documentation on
Infinity](https://www.postgresql.org/docs/current/datatype-datetime.html
#DATATYPE-DATETIME-SPECIAL-VALUES)
--
Ticket URL: <https://code.djangoproject.com/ticket/36045>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 30, 2024, 8:32:13 AM12/30/24
to django-...@googlegroups.com
#36045: Add Support for PostgreSQL Infinity and -Infinity in Date/Time Fields
-------------------------------------+-------------------------------------
Reporter: Kavin Bharathi | Owner: (none)
Type: New feature | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: postgres, infinity, | Triage Stage:
datetime | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kavin Bharathi):

* keywords: => postgres, infinity, datetime

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

Django

unread,
Dec 30, 2024, 2:50:43 PM12/30/24
to django-...@googlegroups.com
#36045: Add Support for PostgreSQL Infinity and -Infinity in Date/Time Fields
-------------------------------------+-------------------------------------
Reporter: Kavin Bharathi | Owner: (none)
Type: New feature | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: postgres, infinity, | Triage Stage:
datetime | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

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


Old description:
New description:

**Proposed Feature:**

1. Add support for parsing PostgreSQL's infinity and -infinity values into
Django models.
2. Represent infinity and -infinity using custom Python objects or
constants (e.g., django.db.utils.Infinity and -Infinity).
3. Ensure seamless integration with Django's ORM for querying, inserting,
and updating fields containing these values.
4. Provide a mechanism to serialize and deserialize these values (e.g.,
JSON serialization).

**Use Cases:**

1. Handling open-ended event durations.
2. Representing date ranges without a start or end boundary.
3. Supporting applications that already use these values in their
PostgreSQL databases.

**Benefits:**

1. Enables Django developers to work with PostgreSQL databases more
effectively.
2. Expands Django's compatibility with PostgreSQL's advanced features.

**Potential Challenges:**

1. Ensuring backward compatibility with existing applications.
2. Deciding on a Python representation for infinity that integrates well
with Django's ORM and other Python libraries.

**References:**

[https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-
DATETIME-SPECIAL-VALUES) PostgreSQL Documentation on Infinity]

--
Comment:

Thanks for the proposal, however, I don't think we can accept it without a
consensus on [https://forum.djangoproject.com/c/internals/5 the Django
Forum]. As you note, there are a lot of open questions about how it could
be implemented, so the design proposal would need to be solid. It's also
unclear if it's a good idea to expose a database-specific feature like
this that - as far as I'm aware - only applies to PostgreSQL. If you want
to pursue this, I would try to implement it as a custom field so you can
better understand what changes are required. Then, if you believe the
changes should be incorporated in Django, make your proposal on the forum.
--
Ticket URL: <https://code.djangoproject.com/ticket/36045#comment:2>
Reply all
Reply to author
Forward
0 new messages