Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:django-nonrel/mongodb-engine

  • Loading branch information...
commit 2d24149c9ccdbeb5355725a62c5da1604fc655cd 2 parents 18b4788 + fae0467
@jonashaag jonashaag authored
Showing with 13 additions and 3 deletions.
  1. +6 −3 django_mongodb_engine/compiler.py
  2. +7 −0 tests/query/tests.py
View
9 django_mongodb_engine/compiler.py
@@ -239,9 +239,12 @@ def add_filters(self, filters, query=None):
else:
existing.update(lookup)
else:
- # {'$gt': o1} + {'$lt': o2} --> {'$gt': o1, '$lt': o2}
- assert all(key not in existing for key in lookup.keys()), [lookup, existing]
- existing.update(lookup)
+ if '$in' in lookup and '$in' in existing:
+ existing['$in'] = list(set(lookup['$in'] + existing['$in']))
+ else:
+ # {'$gt': o1} + {'$lt': o2} --> {'$gt': o1, '$lt': o2}
+ assert all(key not in existing for key in lookup.keys()), [lookup, existing]
+ existing.update(lookup)
else:
key = '$nin' if self._negated else '$all'
existing.setdefault(key, []).append(lookup)
View
7 tests/query/tests.py
@@ -234,6 +234,13 @@ def test_multiple_filter_on_same_name(self):
[]
)
+ # Tests chaining on primary keys
+ blog_id = Blog.objects.get().id
+ self.assertEqual(
+ Blog.objects.filter(pk = blog_id).filter(pk = blog_id).get(),
+ Blog.objects.get()
+ )
+
def test_negated_Q(self):
blogs = [Blog.objects.create(title=title) for title in
('blog', 'other blog', 'another blog')]
Please sign in to comment.
Something went wrong with that request. Please try again.