Skip to content

Commit 3e3ee82

Browse files
committed
clean up test failures
1 parent c284d16 commit 3e3ee82

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

django_mongodb/features.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ 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 subqueries doesn't work.
83+
# contains with Exists() doesn't work:
84+
# https://github.com/mongodb-labs/django-mongodb/issues/204
8485
"model_fields_.test_arrayfield.QueryingTests.test_contains_subquery",
86+
# icontains doesn't work on ArrayField:
8587
# Unsupported conversion from array to string in $convert
8688
"model_fields_.test_arrayfield.QueryingTests.test_icontains",
87-
# None is $in None
88-
"model_fields_.test_arrayfield.QueryingTests.test_in_as_F_object",
8989
}
9090
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
9191
_django_test_expected_failures_bitwise = {

tests/model_fields_/test_arrayfield.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,8 @@ def test_in_subquery(self):
289289

290290
@unittest.expectedFailure
291291
def test_in_including_F_object(self):
292-
# This test asserts that Array objects passed to filters can be
293-
# constructed to contain F objects. This currently doesn't work as the
294-
# psycopg mogrify method that generates the ARRAY() syntax is
295-
# expecting literals, not column references (#27095).
292+
# Array objects passed to filters can be constructed to contain
293+
# F objects. This doesn't work on PostgreSQL either (#27095).
296294
self.assertSequenceEqual(
297295
NullableIntegerArrayModel.objects.filter(field__in=[[models.F("id")]]),
298296
self.objs[:2],
@@ -301,7 +299,12 @@ def test_in_including_F_object(self):
301299
def test_in_as_F_object(self):
302300
self.assertSequenceEqual(
303301
NullableIntegerArrayModel.objects.filter(field__in=[models.F("field")]),
304-
self.objs[:4],
302+
# Unlike PostgreSQL, MongoDB returns documents with field=null,
303+
# i.e. null is in [null]. It seems okay to leave this alone rather
304+
# than filtering out null in all $in queries. Feel free to
305+
# reconsider this decision if the behavior is problematic in some
306+
# other query.
307+
self.objs,
305308
)
306309

307310
def test_contains(self):

0 commit comments

Comments
 (0)