Skip to content

Commit 797da9e

Browse files
committed
make converesion explicitly change for null equality
1 parent f783c8e commit 797da9e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

django_mongodb_backend/query_conversion/expression_converters.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def convert(cls, args):
7777
# Check if first argument is a simple field reference.
7878
if (field_name := cls.convert_path_name(field_expr)) and cls.is_simple_value(value):
7979
if cls.operator == "$eq":
80-
return {field_name: {"$exists": False} if value is None else value}
80+
if value is None:
81+
return {"$and": [{field_name: {"$exists": True}}, {field_name: None}]}
82+
return {field_name: value}
8183
return {field_name: {cls.operator: value}}
8284
return None
8385

@@ -131,7 +133,7 @@ def convert(cls, in_args):
131133
field_expr, values = in_args
132134
# Check if first argument is a simple field reference
133135
# Check if second argument is a list of simple values
134-
if (field_name := cls.convert_path_name(field_expr)) and (
136+
if (field_name := cls.(field_expr)) and (
135137
isinstance(values, list | tuple | set)
136138
and all(cls.is_simple_value(v) for v in values)
137139
):

0 commit comments

Comments
 (0)