Skip to content

Commit 26b63d9

Browse files
committed
Remove contained_by and all lookups for supported lookups.
1 parent 693736f commit 26b63d9

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

django_mongodb_backend/fields/embedded_model_array.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ class _EmbeddedModelArrayOutputField(ArrayField):
9292
"gte",
9393
"lt",
9494
"lte",
95-
"all",
96-
"contained_by",
9795
}
9896

9997
def get_lookup(self, name):
@@ -166,23 +164,6 @@ class EmbeddedModelArrayFieldLessThanOrEqual(
166164
pass
167165

168166

169-
@_EmbeddedModelArrayOutputField.register_lookup
170-
class EmbeddedModelArrayFieldAll(EmbeddedModelArrayFieldBuiltinLookup, Lookup):
171-
lookup_name = "all"
172-
get_db_prep_lookup_value_is_iterable = False
173-
174-
def as_mql(self, compiler, connection):
175-
lhs_mql = process_lhs(self, compiler, connection)
176-
values = process_rhs(self, compiler, connection)
177-
return {
178-
"$and": [
179-
{"$ne": [lhs_mql, None]},
180-
{"$ne": [values, None]},
181-
{"$setIsSubset": [values, lhs_mql]},
182-
]
183-
}
184-
185-
186167
class KeyTransform(Transform):
187168
def __init__(self, key_name, array_field, *args, **kwargs):
188169
super().__init__(*args, **kwargs)

tests/model_fields_/test_embedded_model_array.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,6 @@ def test_filter_unsupported_lookups(self):
182182
self.assertCountEqual(MuseumExhibit.objects.filter(**kwargs), [])
183183
self.assertIn(f"'field': '{lookup}'", captured_queries[0]["sql"])
184184

185-
def test_all_filter(self):
186-
self.assertCountEqual(
187-
MuseumExhibit.objects.filter(sections__section_number__all=[1, 2]), [self.wonders]
188-
)
189-
190-
def test_contained_by(self):
191-
self.assertCountEqual(
192-
MuseumExhibit.objects.filter(sections__section_number__contained_by=[1, 2, 3]),
193-
[self.egypt, self.new_descoveries, self.wonders, self.lost_empires],
194-
)
195-
196185
def test_len_filter(self):
197186
self.assertCountEqual(MuseumExhibit.objects.filter(sections__len=10), [])
198187
self.assertCountEqual(
@@ -305,9 +294,8 @@ def test_foreign_field_exact(self):
305294
self.assertCountEqual(qs, [self.egypt_tour, self.wonders_tour])
306295

307296
def test_foreign_field_with_slice(self):
308-
# Only wonders exhibit has exactly two sections, and this slice matches first two
309-
qs = Tour.objects.filter(exhibit__sections__0_2__section_number__all=[1, 2])
310-
self.assertEqual(list(qs), [self.wonders_tour])
297+
qs = Tour.objects.filter(exhibit__sections__0_2__section_number__in=[1, 2])
298+
self.assertCountEqual(qs, [self.wonders_tour, self.egypt_tour])
311299

312300

313301
@isolate_apps("model_fields_")

0 commit comments

Comments
 (0)