Skip to content

Commit 1e393c4

Browse files
committed
simplify contains
1 parent 233d086 commit 1e393c4

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

django_mongodb/fields/array.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,7 @@ class ArrayContains(ArrayRHSMixin, FieldGetDbPrepValueMixin, Lookup):
245245
def as_mql(self, compiler, connection):
246246
lhs_mql = process_lhs(self, compiler, connection)
247247
value = process_rhs(self, compiler, connection)
248-
return {
249-
"$eq": [
250-
{
251-
"$cond": {
252-
"if": {"$eq": [lhs_mql, None]},
253-
"then": False,
254-
"else": {"$setIsSubset": [value, lhs_mql]},
255-
}
256-
},
257-
True,
258-
]
259-
}
248+
return {"$and": [{"$ne": [lhs_mql, None]}, {"$setIsSubset": [value, lhs_mql]}]}
260249

261250

262251
@ArrayField.register_lookup

0 commit comments

Comments
 (0)