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.
* 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>
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>
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>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:4>
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>
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>
* cc: Sergey Fedoseev (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:7>
* cc: Srinivas Reddy Thatiparthy (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29916#comment:8>
* 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>
* 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>
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>
* 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>
* 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>