Opened 6 years ago
Closed 5 years ago
#29916 closed New feature (fixed)
Add lower_inc, upper_inc, lower_inf, and upper_inf range lookups
Reported by: | Peter J. Farrell | Owned by: | Dulmandakh |
---|---|---|---|
Component: | contrib.postgres | Version: | dev |
Severity: | Normal | Keywords: | lower_inf, upper_inf, lower_inc, upper_inc |
Cc: | Sergey Fedoseev, Srinivas Reddy Thatiparthy | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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:
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.
Change History (13)
comment:1 by , 6 years ago
Owner: | set to |
---|
comment:2 by , 6 years ago
Description: | modified (diff) |
---|
comment:3 by , 6 years ago
Description: | modified (diff) |
---|
comment:4 by , 6 years ago
Summary: | Add additional Postgres lookups to gain parity with supported range functions in Postgres → Add isempty, lower_inc, upper_inc, lower_inf, and upper_inf range lookups |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:5 by , 6 years ago
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.
comment:6 by , 6 years ago
Description: | modified (diff) |
---|
comment:7 by , 6 years ago
Cc: | added |
---|
comment:8 by , 6 years ago
Cc: | added |
---|
comment:9 by , 6 years ago
Keywords: | isempty removed |
---|---|
Summary: | Add isempty, lower_inc, upper_inc, lower_inf, and upper_inf range lookups → Add lower_inc, upper_inc, lower_inf, and upper_inf range lookups |
comment:10 by , 5 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
Owner: | changed from | to
Patch needs improvement: | set |
Version: | 2.1 → master |
comment:11 by , 5 years ago
I'm not a native English speaker, so have trouble writing documentation. Please help.
comment:12 by , 5 years ago
Needs documentation: | unset |
---|---|
Patch needs improvement: | unset |
Triage Stage: | Accepted → Ready for checkin |
I added docs and release notes.
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.