Skip to content

Commit 1e331fa

Browse files
committed
Revert ArrayField changes
1 parent 3ddce45 commit 1e331fa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

django_mongodb_backend/fields/array.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ def get_subquery_wrapping_pipeline(self, compiler, connection, field_name, expr)
326326
def as_mql(self, compiler, connection):
327327
lhs_mql = process_lhs(self, compiler, connection)
328328
value = process_rhs(self, compiler, connection)
329-
return {"$and": [{"$isArray": lhs_mql}, {"$size": {"$setIntersection": [value, lhs_mql]}}]}
329+
return {
330+
"$and": [{"$ne": [lhs_mql, None]}, {"$size": {"$setIntersection": [value, lhs_mql]}}]
331+
}
330332

331333

332334
@ArrayField.register_lookup
@@ -336,7 +338,7 @@ class ArrayLenTransform(Transform):
336338

337339
def as_mql(self, compiler, connection):
338340
lhs_mql = process_lhs(self, compiler, connection)
339-
return {"$cond": {"if": {"$isArray": lhs_mql}, "then": {"$size": lhs_mql}, "else": None}}
341+
return {"$cond": {"if": {"$eq": [lhs_mql, None]}, "then": None, "else": {"$size": lhs_mql}}}
340342

341343

342344
@ArrayField.register_lookup

0 commit comments

Comments
 (0)