Merge branch 'master' of github.com:MongoEngine/mongoengine into abarto-feature/allow-setting-read-concern-queryset

This commit is contained in:
Bastien Gérard 2020-03-03 23:50:36 +01:00
commit ba34589065
3 changed files with 9 additions and 2 deletions

View File

@ -7,6 +7,7 @@ Development
=========== ===========
- (Fill this out as you fix issues and develop your features). - (Fill this out as you fix issues and develop your features).
- Add Mongo 4.0 to Travis - Add Mongo 4.0 to Travis
- Fixed a bug causing inaccurate query results, while combining ``__raw__`` and regular filters for the same field #2264
Changes in 0.19.1 Changes in 0.19.1
================= =================

View File

@ -169,9 +169,9 @@ def query(_doc_cls=None, **kwargs):
key = ".".join(parts) key = ".".join(parts)
if op is None or key not in mongo_query: if key not in mongo_query:
mongo_query[key] = value mongo_query[key] = value
elif key in mongo_query: else:
if isinstance(mongo_query[key], dict) and isinstance(value, dict): if isinstance(mongo_query[key], dict) and isinstance(value, dict):
mongo_query[key].update(value) mongo_query[key].update(value)
# $max/minDistance needs to come last - convert to SON # $max/minDistance needs to come last - convert to SON

View File

@ -24,6 +24,12 @@ class TestTransform(unittest.TestCase):
} }
assert transform.query(friend__age__gte=30) == {"friend.age": {"$gte": 30}} assert transform.query(friend__age__gte=30) == {"friend.age": {"$gte": 30}}
assert transform.query(name__exists=True) == {"name": {"$exists": True}} assert transform.query(name__exists=True) == {"name": {"$exists": True}}
assert transform.query(name=["Mark"], __raw__={"name": {"$in": "Tom"}}) == {
"$and": [{"name": ["Mark"]}, {"name": {"$in": "Tom"}}]
}
assert transform.query(name__in=["Tom"], __raw__={"name": "Mark"}) == {
"$and": [{"name": {"$in": ["Tom"]}}, {"name": "Mark"}]
}
def test_transform_update(self): def test_transform_update(self):
class LisDoc(Document): class LisDoc(Document):