Skip to content

Commit aff20ae

Browse files
committed
fix test_contains_subquery
1 parent 08ae4b4 commit aff20ae

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

django_mongodb_backend/features.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
8080
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
8181
# GenericRelation.value_to_string() assumes integer pk.
8282
"contenttypes_tests.test_fields.GenericRelationTests.test_value_to_string",
83-
# contains with Exists() doesn't work:
84-
# https://github.com/mongodb-labs/django-mongodb/issues/204
85-
"model_fields_.test_arrayfield.QueryingTests.test_contains_subquery",
8683
# overlap with values() returns no results:
8784
# https://github.com/mongodb-labs/django-mongodb/issues/209
8885
"model_fields_.test_arrayfield.QueryingTests.test_overlap_values",

django_mongodb_backend/fields/array.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,13 @@ class ArrayContains(ArrayRHSMixin, FieldGetDbPrepValueMixin, Lookup):
244244
def as_mql(self, compiler, connection):
245245
lhs_mql = process_lhs(self, compiler, connection)
246246
value = process_rhs(self, compiler, connection)
247-
return {"$and": [{"$ne": [lhs_mql, None]}, {"$setIsSubset": [value, lhs_mql]}]}
247+
return {
248+
"$and": [
249+
{"$ne": [lhs_mql, None]},
250+
{"$ne": [value, None]},
251+
{"$setIsSubset": [value, lhs_mql]},
252+
]
253+
}
248254

249255

250256
@ArrayField.register_lookup

0 commit comments

Comments
 (0)