diff options
Diffstat (limited to 'docs/topics/db')
| -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``. |
