[Django] #36718: Enable JSON negative indexing for Oracle 21c+ using [last-N]

7 views
Skip to first unread message

Django

unread,
Nov 8, 2025, 10:06:43 AM (3 days ago) Nov 8
to django-...@googlegroups.com
#36718: Enable JSON negative indexing for Oracle 21c+ using [last-N]
-------------------------------------+-------------------------------------
Reporter: Clifford Gama | Type: New
| feature
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: JSONField array | Triage Stage:
negative indexing | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Follow up to #36085 which added negative indexing for sqlite (as a new
feature for 6.0).

While doing some reading on JSON queries on Oracle, I found that you
[https://docs.oracle.com/en/database/oracle/oracle-database/21/adjsn/json-
path-expressions.html can index elements from the right] by using
`[last-N]`.

> An array index can also have the form last - N, where - is a minus sign
(hyphen) and N is a literal whole number (0, 1, 2,…) that is no greater
than the array size minus 1. The next-to-last array element can be
referenced using index last-1, the second-to-last by index last-2, and so
on. Whitespace surrounding the minus sign (hyphen) is ignored.

I think we can use this to support negative indexing on Oracle versions
that support `[last-N]`. Currently, trying to do so raises a
`NotSupportedError` per #36085 which was focused on sqlite.

I can't find Oracle release notes specifying when [last-N] indexing was
added, but the note I quoted is only available in 21c+ docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/36718>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 8, 2025, 10:10:57 AM (3 days ago) Nov 8
to django-...@googlegroups.com
#36718: Enable JSON negative indexing for Oracle 21c+ using [last-N]
-------------------------------------+-------------------------------------
Reporter: Clifford Gama | Owner: Clifford
| Gama
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: JSONField array | Triage Stage:
negative indexing | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* has_patch: 0 => 1
* owner: (none) => Clifford Gama
* status: new => assigned

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

Django

unread,
Nov 10, 2025, 9:16:30 AM (yesterday) Nov 10
to django-...@googlegroups.com
#36718: Enable JSON negative indexing for Oracle 21c+ using [last-N]
-------------------------------------+-------------------------------------
Reporter: Clifford Gama | Owner: Clifford
| Gama
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: JSONField array | Triage Stage: Accepted
negative indexing |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Unreviewed => Accepted

Comment:

Thanks Clifford. Leaving as a "feature" since we should document, but not
punting to new-features since there is a bugfix aspect, as we shouldn't be
raising `NotSupportedError` for behavior that the database supports but we
just haven't implemented.
--
Ticket URL: <https://code.djangoproject.com/ticket/36718#comment:2>
Reply all
Reply to author
Forward
0 new messages