[Django] #36845: Allow negative index in Left() for PostgreSQL

7 views
Skip to first unread message

Django

unread,
Jan 6, 2026, 8:27:15 AMJan 6
to django-...@googlegroups.com
#36845: Allow negative index in Left() for PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Christopher | Type: New
Covington | feature
Status: new | Component: Database
| layer (models, ORM)
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
PostgreSQL has supported negative indices since v9.1
https://www.postgresql.org/docs/9.1/functions-string.html as right side
trim length--just like Python string slicing.

Targeting the check and ValueError in `Left.__init__()` more precisely
will enable straightforward translation of a common string manipulation
pattern from Python:
`field[:-3]`

to Django ORM for PostgreSQL:
`Left('field', -3)`

For other databases I would propose initially carrying forward the non-
negative requirement. If there's interest, a Python implementation of
negative index (right side trim length) support, or something cleverer,
could follow up as separate discussion and work.
--
Ticket URL: <https://code.djangoproject.com/ticket/36845>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 6, 2026, 10:38:54 AMJan 6
to django-...@googlegroups.com
#36845: Allow negative index in Left() for PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Christopher | Owner: Moksha
Covington | Choksi
Type: New feature | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Moksha Choksi):

* owner: (none) => Moksha Choksi
* status: new => assigned

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

Django

unread,
Jan 7, 2026, 5:07:46 AMJan 7
to django-...@googlegroups.com
#36845: Allow negative index in Left() for PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Christopher | Owner: Moksha
Covington | Choksi
Type: New feature | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Moksha Choksi):

* has_patch: 0 => 1

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

Django

unread,
Jan 9, 2026, 11:47:23 AMJan 9
to django-...@googlegroups.com
#36845: Allow negative index in Left() for PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Christopher | Owner: Moksha
Covington | Choksi
Type: New feature | Status: closed
Component: Database layer | Version: 6.0
(models, ORM) | Resolution:
Severity: Normal | needsnewfeatureprocess
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* easy: 1 => 0
* has_patch: 1 => 0
* resolution: => needsnewfeatureprocess
* status: assigned => closed

Comment:

Hi, thanks for the idea. It would help to know what advantage this would
provide over using `Right()`. The best place to have this discussion would
be on the new features board at django/new-features.
--
Ticket URL: <https://code.djangoproject.com/ticket/36845#comment:3>
Reply all
Reply to author
Forward
0 new messages