Opened 3 weeks ago

Closed 10 days ago

#36718 closed New feature (fixed)

Enable JSON negative indexing for Oracle 21c+ using [last-N]

Reported by: Clifford Gama Owned by: Clifford Gama
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: JSONField array negative indexing
Cc: 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

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 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.

Change History (4)

comment:1 by Clifford Gama, 3 weeks ago

Has patch: set
Owner: set to Clifford Gama
Status: newassigned

comment:2 by Jacob Walls, 3 weeks ago

Triage Stage: UnreviewedAccepted

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.

comment:3 by Mariusz Felisiak, 10 days ago

Triage Stage: AcceptedReady for checkin

comment:4 by GitHub <noreply@…>, 10 days ago

Resolution: fixed
Status: assignedclosed

In 7e4c4f4:

Fixed #36718 -- Added JSONField support for negative array indexing on Oracle 21c+.

Note: See TracTickets for help on using tickets.
Back to Top