Skip to content

Commit dacf0bb

Browse files
committed
clean up test failures
1 parent 1cbcbc4 commit dacf0bb

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

django_mongodb/features.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,12 @@ class DatabaseFeatures(BaseDatabaseFeatures):
8282
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
8383
# GenericRelation.value_to_string() assumes integer pk.
8484
"contenttypes_tests.test_fields.GenericRelationTests.test_value_to_string",
85-
# contains with subqueries doesn't work.
85+
# contains with Exists() doesn't work:
86+
# https://github.com/mongodb-labs/django-mongodb/issues/204
8687
"model_fields_.test_arrayfield.QueryingTests.test_contains_subquery",
88+
# icontains doesn't work on ArrayField:
8789
# Unsupported conversion from array to string in $convert
8890
"model_fields_.test_arrayfield.QueryingTests.test_icontains",
89-
# $lt treats null values as zero.
90-
"model_fields_.test_arrayfield.QueryingTests.test_lt",
91-
"model_fields_.test_arrayfield.QueryingTests.test_len",
92-
"model_fields_.test_arrayfield.QueryingTests.test_index_chained",
93-
# None is $in None
94-
"model_fields_.test_arrayfield.QueryingTests.test_in_as_F_object",
9591
}
9692
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
9793
_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)