Compilation of combinations - simple $or now works

This commit is contained in:
Harry Marr
2010-10-03 21:26:26 +01:00
parent 62388cb740
commit a3c46fec07
2 changed files with 33 additions and 13 deletions

View File

@@ -1432,5 +1432,19 @@ class NewQTest(unittest.TestCase):
query = (q1 & q2).to_query(TestDoc)
self.assertEqual(query, {'x': {'$lt': 7, '$gt': 3}})
def test_or_combination(self):
class TestDoc(Document):
x = IntField()
q1 = NewQ(x__lt=3)
q2 = NewQ(x__gt=7)
query = (q1 | q2).to_query(TestDoc)
self.assertEqual(query, {
'$or': [
{'x': {'$lt': 3}},
{'x': {'$gt': 7}},
]
})
if __name__ == '__main__':
unittest.main()