[Django] #29916: Add additional Postgres lookups to gain parity with supported range functions in Postgres

18 views
Skip to first unread message

Django

unread,
Nov 2, 2018, 2:59:29 PM11/2/18
to django-...@googlegroups.com
#29916: Add additional Postgres lookups to gain parity with supported range
functions in Postgres
-------------------------------------+-------------------------------------
Reporter: Peter J. | Owner: (none)
Farrell |
Type: New | Status: assigned
feature |
Component: | Version: 2.1
contrib.postgres | Keywords: lower_inf,
Severity: Normal | upper_inf, isempty, lower_inc,
Triage Stage: | upper_inc
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Add support for following functions for Postgres range fields that are
currently not supported in Django:

isempty
lower_inc
upper_inc
lower_inf
upper_inf

Example code:
[https://gist.github.com/peterfarrell/5c7b8d80319563813caba6320b568829]

These can all be implemented as new ORM lookups for the Postgres range
type fields so the Django ORM can gain parity with functionality available
in Postgres range fields.

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

Django

unread,
Nov 2, 2018, 3:02:15 PM11/2/18
to django-...@googlegroups.com
#29916: Add additional Postgres lookups to gain parity with supported range
functions in Postgres
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage:
upper_inf, isempty, lower_inc, | Unreviewed
upper_inc |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Peter J. Farrell):

* owner: (none) => Peter J. Farrell


Comment:

I am volunteering to make a PR to add support for these 5 functions. I
will start work on a PR (including tests and documentation) if this ticket
is accepted.

I have two working custom lookups (lower_inf and upper_inf) already built
(see the gist linked in the main ticket). They need to add casting for
different range types to improve compatibility however the concept is
sound.

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

Django

unread,
Nov 2, 2018, 3:05:16 PM11/2/18
to django-...@googlegroups.com
#29916: Add additional Postgres lookups to gain parity with supported range
functions in Postgres
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage:
upper_inf, isempty, lower_inc, | Unreviewed
upper_inc |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Peter J. Farrell:

Old description:

> Add support for following functions for Postgres range fields that are
> currently not supported in Django:
>
> isempty
> lower_inc
> upper_inc
> lower_inf
> upper_inf
>
> Example code:
> [https://gist.github.com/peterfarrell/5c7b8d80319563813caba6320b568829]
>
> These can all be implemented as new ORM lookups for the Postgres range
> type fields so the Django ORM can gain parity with functionality
> available in Postgres range fields.

New description:

Add support for following functions for Postgres range fields that are
currently not supported in Django:

* isempty
* lower_inc
* upper_inc
* lower_inf
* upper_inf

Example usage:

{{{#!python
MyObject.objects.filter(date_range__upper_inf=True) # for infinity
MyObject.objects.filter(date_range__upper_inf=False) # for not infinity
}}}

Example code:
[https://gist.github.com/peterfarrell/5c7b8d80319563813caba6320b568829]

These can all be implemented as new ORM lookups for the Postgres range
type fields so the Django ORM can gain parity with functionality available
in Postgres range fields.

--

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

Django

unread,
Nov 2, 2018, 3:06:39 PM11/2/18
to django-...@googlegroups.com
#29916: Add additional Postgres lookups to gain parity with supported range
functions in Postgres
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage:
upper_inf, isempty, lower_inc, | Unreviewed
upper_inc |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Peter J. Farrell:

Old description:

> Add support for following functions for Postgres range fields that are


> currently not supported in Django:
>

> * isempty
> * lower_inc
> * upper_inc
> * lower_inf
> * upper_inf
>
> Example usage:
>
> {{{#!python
> MyObject.objects.filter(date_range__upper_inf=True) # for infinity
> MyObject.objects.filter(date_range__upper_inf=False) # for not infinity
> }}}
>

> Example code:
> [https://gist.github.com/peterfarrell/5c7b8d80319563813caba6320b568829]
>
> These can all be implemented as new ORM lookups for the Postgres range
> type fields so the Django ORM can gain parity with functionality
> available in Postgres range fields.

New description:

Add support for following functions for Postgres range fields that are
currently not supported in Django:

* isempty


* lower_inc
* upper_inc
* lower_inf
* upper_inf

[https://www.postgresql.org/docs/9.3/static/functions-range.html]

Example usage:

{{{#!python
MyObject.objects.filter(date_range__upper_inf=True) # for infinity
MyObject.objects.filter(date_range__upper_inf=False) # for not infinity
}}}

Example code:
[https://gist.github.com/peterfarrell/5c7b8d80319563813caba6320b568829]

These can all be implemented as new ORM lookups for the Postgres range
type fields so the Django ORM can gain parity with functionality available
in Postgres range fields.

--

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

Django

unread,
Nov 2, 2018, 6:26:27 PM11/2/18
to django-...@googlegroups.com
#29916: Add isempty, lower_inc, upper_inc, lower_inf, and upper_inf range lookups

-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Accepted
upper_inf, isempty, lower_inc, |
upper_inc |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
Nov 3, 2018, 9:18:30 PM11/3/18
to django-...@googlegroups.com
#29916: Add isempty, lower_inc, upper_inc, lower_inf, and upper_inf range lookups
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Accepted
upper_inf, isempty, lower_inc, |
upper_inc |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Peter J. Farrell):

The `isempty` postgres function is already implemented and documented.
However, `lower` and `upper` functions are implemented by as `startswith`
and `endswith` which is a bit confusing unless you look at the code. So I
am planning on improving the documentation to indicated which postgres
function those lookups map to.

--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:5>

Django

unread,
Nov 5, 2018, 2:03:36 PM11/5/18
to django-...@googlegroups.com
#29916: Add isempty, lower_inc, upper_inc, lower_inf, and upper_inf range lookups
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Accepted
upper_inf, isempty, lower_inc, |
upper_inc |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Peter J. Farrell:

Old description:

> Add support for following functions for Postgres range fields that are


> currently not supported in Django:
>

> * isempty
> * lower_inc
> * upper_inc
> * lower_inf
> * upper_inf
>
> [https://www.postgresql.org/docs/9.3/static/functions-range.html]
>
> Example usage:
>
> {{{#!python
> MyObject.objects.filter(date_range__upper_inf=True) # for infinity
> MyObject.objects.filter(date_range__upper_inf=False) # for not infinity
> }}}
>

> Example code:
> [https://gist.github.com/peterfarrell/5c7b8d80319563813caba6320b568829]
>
> These can all be implemented as new ORM lookups for the Postgres range
> type fields so the Django ORM can gain parity with functionality
> available in Postgres range fields.

New description:

Add support for following functions for Postgres range fields that are
currently not supported in Django:

* lower_inc


* upper_inc
* lower_inf
* upper_inf

[https://www.postgresql.org/docs/9.3/static/functions-range.html]

Example usage:

{{{#!python
MyObject.objects.filter(date_range__upper_inf=True) # for infinity
MyObject.objects.filter(date_range__upper_inf=False) # for not infinity
}}}

Example code:
[https://gist.github.com/peterfarrell/5c7b8d80319563813caba6320b568829]

These can all be implemented as new ORM lookups for the Postgres range
type fields so the Django ORM can gain parity with functionality available
in Postgres range fields.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:6>

Django

unread,
Nov 7, 2018, 4:21:25 AM11/7/18
to django-...@googlegroups.com
#29916: Add isempty, lower_inc, upper_inc, lower_inf, and upper_inf range lookups
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Accepted
upper_inf, isempty, lower_inc, |
upper_inc |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sergey Fedoseev):

* cc: Sergey Fedoseev (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:7>

Django

unread,
Nov 10, 2018, 10:37:04 AM11/10/18
to django-...@googlegroups.com
#29916: Add isempty, lower_inc, upper_inc, lower_inf, and upper_inf range lookups
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Accepted
upper_inf, isempty, lower_inc, |
upper_inc |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Srinivas Reddy Thatiparthy):

* cc: Srinivas Reddy Thatiparthy (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:8>

Django

unread,
Nov 13, 2018, 12:51:39 AM11/13/18
to django-...@googlegroups.com
#29916: Add lower_inc, upper_inc, lower_inf, and upper_inf range lookups

-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner: Peter J.
| Farrell
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Accepted
upper_inf, lower_inc, upper_inc |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Peter J. Farrell):

* keywords: lower_inf, upper_inf, isempty, lower_inc, upper_inc =>
lower_inf, upper_inf, lower_inc, upper_inc


--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:9>

Django

unread,
Nov 6, 2019, 5:39:42 AM11/6/19
to django-...@googlegroups.com
#29916: Add lower_inc, upper_inc, lower_inf, and upper_inf range lookups
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner:
| Dulmandakh

Type: New feature | Status: assigned
Component: contrib.postgres | Version: master

Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Accepted
upper_inf, lower_inc, upper_inc |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

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

* owner: Peter J. Farrell => Dulmandakh
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* version: 2.1 => master
* needs_docs: 0 => 1


Comment:

[https://github.com/django/django/pull/12030 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:10>

Django

unread,
Nov 7, 2019, 4:05:12 AM11/7/19
to django-...@googlegroups.com
#29916: Add lower_inc, upper_inc, lower_inf, and upper_inf range lookups
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner:
| Dulmandakh
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Accepted
upper_inf, lower_inc, upper_inc |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

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

Comment (by Dulmandakh):

I'm not a native English speaker, so have trouble writing documentation.
Please help.

--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:11>

Django

unread,
Nov 14, 2019, 9:42:18 AM11/14/19
to django-...@googlegroups.com
#29916: Add lower_inc, upper_inc, lower_inf, and upper_inf range lookups
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner:
| Dulmandakh
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: lower_inf, | Triage Stage: Ready for
upper_inf, lower_inc, upper_inc | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0
* needs_docs: 1 => 0
* stage: Accepted => Ready for checkin


Comment:

I added docs and release notes.

--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:12>

Django

unread,
Nov 14, 2019, 5:13:34 PM11/14/19
to django-...@googlegroups.com
#29916: Add lower_inc, upper_inc, lower_inf, and upper_inf range lookups
-------------------------------------+-------------------------------------
Reporter: Peter J. Farrell | Owner:
| Dulmandakh
Type: New feature | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed

Keywords: lower_inf, | Triage Stage: Ready for
upper_inf, lower_inc, upper_inc | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"24b9f5082344a127147266dd52d5d2dcd1c9cb44" 24b9f508]:
{{{
#!CommitTicketReference repository=""
revision="24b9f5082344a127147266dd52d5d2dcd1c9cb44"
Fixed #29916 -- Added lower_inc, lower_inf, upper_inc, and upper_inf
lookups for RangeFields.

Co-Authored-By: Mariusz Felisiak <felisiak...@gmail.com>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:13>

Reply all
Reply to author
Forward
0 new messages