Hello, I noticed $and doesn't work in some conditions:
def test_and_and_or_together(self): f = self.bind.db.coll.find assert 1 == f({ '$and': [ {'$or': [{'a': 2}, {'a': 3}]}, {'_id': {'$eq': 'foo'}} ]}).count()
this test should pass, but instead fails.
I can just remove the $and to make it pass
def test_and_and_or_together(self): f = self.bind.db.coll.find assert 1 == f({ '$or': [{'a': 2}, {'a': 3}], '_id': {'$eq': 'foo'} }).count()
but in a mongo shell works even with $and:
$ ~ mongo MongoDB shell version v3.6.3 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.6.3 Server has startup warnings: 2018-04-26T08:59:08.408+0200 I STORAGE [initandlisten] 2018-04-26T08:59:08.408+0200 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2018-04-26T08:59:08.408+0200 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2018-04-26T08:59:08.775+0200 I CONTROL [initandlisten] 2018-04-26T08:59:08.775+0200 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2018-04-26T08:59:08.775+0200 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2018-04-26T08:59:08.776+0200 I CONTROL [initandlisten] > use test switched to db test > > db.coll.insert({'_id':'foo', 'a':2, 'c':[1,2,3], 'z': {'egg': 'spam', 'spam': 'egg'}}) WriteResult({ "nInserted" : 1 }) > db.coll.find({'$and': [{'$or': [{'a': 2}, {'a': 3}]}, {'_id': {'$eq': 'foo'}}]}) { "_id" : "foo", "a" : 2, "c" : [ 1, 2, 3 ], "z" : { "egg" : "spam", "spam" : "egg" } } >
Anonymous