diff options
| author | Clifford Gama <cliffygamy@gmail.com> | 2025-10-24 23:38:52 +0200 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-10-29 15:00:52 -0400 |
| commit | 348ca845385beaddc7c862ff8ec369f041a5088d (patch) | |
| tree | d8772ba51267934216ecb0c2de0786b4702a3310 /docs/topics | |
| parent | be7f68422d4c6ae568a17f1fa91aac67d284df82 (diff) | |
Refs #35381 -- Deprecated using None in JSONExact rhs to mean JSON null.
Key and index lookups are exempt from the deprecation.
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/db/queries.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt index 788a418e4f..b3b6ec125d 100644 --- a/docs/topics/db/queries.txt +++ b/docs/topics/db/queries.txt @@ -1069,6 +1069,11 @@ as JSON ``null``. When querying, :lookup:`isnull=True <isnull>` is used to match SQL ``NULL``, while exact-matching ``JSONNull()`` is used to match JSON ``null``. +.. deprecated:: 6.1 + + Exact-matching ``None`` in a query to mean JSON ``null`` is deprecated. + After the deprecation period, it will be interpreted as SQL ``NULL``. + .. versionchanged:: 6.1 ``JSONNull()`` expression was added. @@ -1080,6 +1085,12 @@ while exact-matching ``JSONNull()`` is used to match JSON ``null``. <Dog: Max> >>> Dog.objects.create(name="Archie", data=JSONNull()) # JSON null. <Dog: Archie> + >>> Dog.objects.filter(data=None) + ...: RemovedInDjango70Warning: Using None as the right-hand side of an + exact lookup on JSONField to mean JSON scalar 'null' is deprecated. Use + JSONNull() instead (or use the __isnull lookup if you meant SQL NULL). + ... + <QuerySet [<Dog: Archie>]> >>> Dog.objects.filter(data=JSONNull()) <QuerySet [<Dog: Archie>]> >>> Dog.objects.filter(data__isnull=True) @@ -1087,6 +1098,9 @@ while exact-matching ``JSONNull()`` is used to match JSON ``null``. >>> Dog.objects.filter(data__isnull=False) <QuerySet [<Dog: Archie>]> +.. RemovedInDjango70Warning: Alter the example with the deprecation warning to: + <QuerySet [<Dog: Max>]>. + Unless you are sure you wish to work with SQL ``NULL`` values, consider setting ``null=False`` and providing a suitable default for empty values, such as ``default=dict``. |
