mirror of
https://github.com/django/django.git
synced 2025-11-28 06:30:00 +00:00
Fixed #25718 -- Made a JSONField lookup value of None match keys that have a null value.
This commit is contained in:
parent
4fe5d84666
commit
c979c0a2b8
9 changed files with 70 additions and 5 deletions
|
|
@ -1083,8 +1083,8 @@ class Query:
|
|||
|
||||
lookup = lookup_class(lhs, rhs)
|
||||
# Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all
|
||||
# uses of None as a query value.
|
||||
if lookup.rhs is None:
|
||||
# uses of None as a query value unless the lookup supports it.
|
||||
if lookup.rhs is None and not lookup.can_use_none_as_rhs:
|
||||
if lookup_name not in ('exact', 'iexact'):
|
||||
raise ValueError("Cannot use None as a query value")
|
||||
return lhs.get_lookup('isnull')(lhs, True)
|
||||
|
|
@ -1215,7 +1215,7 @@ class Query:
|
|||
clause.add(condition, AND)
|
||||
|
||||
require_outer = lookup_type == 'isnull' and condition.rhs is True and not current_negated
|
||||
if current_negated and (lookup_type != 'isnull' or condition.rhs is False):
|
||||
if current_negated and (lookup_type != 'isnull' or condition.rhs is False) and condition.rhs is not None:
|
||||
require_outer = True
|
||||
if (lookup_type != 'isnull' and (
|
||||
self.is_nullable(targets[0]) or
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue