diff options
| author | savanto <savanto@users.noreply.github.com> | 2025-05-13 13:42:58 +0200 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-05-14 13:21:18 +0200 |
| commit | 8620a3b0c79e4e8098b88f1176ed26fad0bf6c5c (patch) | |
| tree | 4d1a2be9331f5aa702ae0b1551fe38a62786990a /docs | |
| parent | a8716f3c4c6d78d38ce86d79c816062346dcc5bf (diff) | |
Fixed #36085 -- Added JSONField support for negative array indexing on SQLite.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/6.0.txt | 3 | ||||
| -rw-r--r-- | docs/topics/db/queries.txt | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt index 611530bb0a..ec2fa37f6f 100644 --- a/docs/releases/6.0.txt +++ b/docs/releases/6.0.txt @@ -208,6 +208,9 @@ Models * :meth:`.QuerySet.raw` now supports models with a :class:`~django.db.models.CompositePrimaryKey`. +* :class:`~django.db.models.JSONField` now supports + :ref:`negative array indexing <key-index-and-path-transforms>` on SQLite. + Pagination ~~~~~~~~~~ diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt index a6819daf01..eb5b323abb 100644 --- a/docs/topics/db/queries.txt +++ b/docs/topics/db/queries.txt @@ -1092,6 +1092,8 @@ Unless you are sure you wish to work with SQL ``NULL`` values, consider setting .. fieldlookup:: jsonfield.key +.. _key-index-and-path-transforms: + Key, index, and path transforms ------------------------------- @@ -1134,6 +1136,22 @@ array: >>> Dog.objects.filter(data__owner__other_pets__0__name="Fishy") <QuerySet [<Dog: Rufus>]> +If the key is a negative integer, it cannot be used in a filter keyword +directly, but you can still use dictionary unpacking to use it in a query: + +.. code-block:: pycon + + >>> Dog.objects.filter(**{"data__owner__other_pets__-1__name": "Fishy"}) + <QuerySet [<Dog: Rufus>]> + +.. admonition:: MySQL, MariaDB, and Oracle + + Negative JSON array indices are not supported. + +.. versionchanged:: 6.0 + + SQLite support for negative JSON array indices was added. + If the key you wish to query by clashes with the name of another lookup, use the :lookup:`contains <jsonfield.contains>` lookup instead. |
