@@ -76,11 +76,14 @@ def convert(cls, args):
76
76
field_expr , value = args
77
77
# Check if first argument is a simple field reference.
78
78
if (field_name := cls .convert_path_name (field_expr )) and cls .is_simple_value (value ):
79
+ query = {"$and" : [{"$exists" : True }]} if value is None else None
80
+ core_check = None
79
81
if cls .operator == "$eq" :
80
- if value is None :
81
- return {"$and" : [{field_name : {"$exists" : True }}, {field_name : None }]}
82
- return {field_name : value }
83
- return {field_name : {cls .operator : value }}
82
+ core_check = {field_name : value }
83
+ if value is None :
84
+ core_check = {field_name : {cls .operator : None }}
85
+ query = query ["$and" ].append (core_check ) if query else core_check
86
+ return query
84
87
return None
85
88
86
89
@@ -133,11 +136,12 @@ def convert(cls, in_args):
133
136
field_expr , values = in_args
134
137
# Check if first argument is a simple field reference
135
138
# Check if second argument is a list of simple values
136
- if (field_name := cls . (field_expr )) and (
139
+ if (field_name := cls .convert_path_name (field_expr )) and (
137
140
isinstance (values , list | tuple | set )
138
141
and all (cls .is_simple_value (v ) for v in values )
139
142
):
140
- return {field_name : {"$in" : values }}
143
+ core_check = {field_name : {"$in" : values }}
144
+ return {"$and" : [{"$exists" : True }, core_check ]} if None in values else core_check
141
145
return None
142
146
143
147
0 commit comments