summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-26 20:21:27 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-26 20:22:34 +0200
commitf78b18f9c815c63a734ffa22ea9c57a2182b6541 (patch)
treebe10642ad783d829cd45c6c0db9ce4ac8e045df2
parent48501c84ad54971af25c10b3544aee91b6275c86 (diff)
downloaddjango-f78b18f9c815c63a734ffa22ea9c57a2182b6541.tar.gz
[4.0.x] Fixed #33820 -- Doc'd "true"/"false"/"null" caveat for JSONField key transforms on SQLite.
Thanks Johnny Metz for the report. Regression in 71ec102b01fcc85acae3819426a4e02ef423b0fa. Backport of e20e5d1557785ba71e8ef0ceb8ccb85bdc13840a from main
-rw-r--r--docs/ref/models/querysets.txt16
-rw-r--r--docs/topics/db/queries.txt6
2 files changed, 22 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 39b53f0dc3..4727c5bb05 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -695,6 +695,14 @@ You can also refer to fields on related models with reverse relations through
pronounced if you include multiple such fields in your ``values()`` query,
in which case all possible combinations will be returned.
+.. admonition:: Special values for ``JSONField`` on SQLite
+
+ Due to the way the ``JSON_EXTRACT`` and ``JSON_TYPE`` SQL functions are
+ implemented on SQLite, and lack of the ``BOOLEAN`` data type,
+ ``values()`` will return ``True``, ``False``, and ``None`` instead of
+ ``"true"``, ``"false"``, and ``"null"`` strings for
+ :class:`~django.db.models.JSONField` key transforms.
+
``values_list()``
~~~~~~~~~~~~~~~~~
@@ -765,6 +773,14 @@ not having any author::
>>> Entry.objects.values_list('authors')
<QuerySet [('Noam Chomsky',), ('George Orwell',), (None,)]>
+.. admonition:: Special values for ``JSONField`` on SQLite
+
+ Due to the way the ``JSON_EXTRACT`` and ``JSON_TYPE`` SQL functions are
+ implemented on SQLite, and lack of the ``BOOLEAN`` data type,
+ ``values_list()`` will return ``True``, ``False``, and ``None`` instead of
+ ``"true"``, ``"false"``, and ``"null"`` strings for
+ :class:`~django.db.models.JSONField` key transforms.
+
``dates()``
~~~~~~~~~~~
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index cf120d53ba..19a29cf508 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -995,6 +995,12 @@ To query for missing keys, use the ``isnull`` lookup::
On PostgreSQL, if only one key or index is used, the SQL operator ``->`` is
used. If multiple operators are used then the ``#>`` operator is used.
+.. admonition:: SQLite users
+
+ On SQLite, ``"true"``, ``"false"``, and ``"null"`` string values will
+ always be interpreted as ``True``, ``False``, and JSON ``null``
+ respectively.
+
.. _containment-and-key-lookups:
Containment and key lookups