Skip to content

Commit 1d6770a

Browse files
committed
More explicit $in checking
1 parent 5562cee commit 1d6770a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

django_mongodb_engine/compiler.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,12 @@ def add_filters(self, filters, query=None):
238238
else:
239239
existing.update(lookup)
240240
else:
241-
# {'$gt': o1} + {'$lt': o2} --> {'$gt': o1, '$lt': o2}
242-
assert all(key not in existing for key in lookup.keys()), [lookup, existing]
243-
existing.update(lookup)
241+
if '$in' in lookup and '$in' in existing:
242+
existing['$in'] = list(set(lookup['$in'] + existing['$in']))
243+
else:
244+
# {'$gt': o1} + {'$lt': o2} --> {'$gt': o1, '$lt': o2}
245+
assert all(key not in existing for key in lookup.keys()), [lookup, existing]
246+
existing.update(lookup)
244247
else:
245248
key = '$nin' if self._negated else '$all'
246249
existing.setdefault(key, []).append(lookup)

0 commit comments

Comments
 (0)