Merge branch 'master' of github.com:MongoEngine/mongoengine into fix_limit0_bug
This commit is contained in:
commit
7b4175fc5c
@ -6,6 +6,7 @@ Changelog
|
|||||||
Development
|
Development
|
||||||
===========
|
===========
|
||||||
- (Fill this out as you fix issues and develop your features).
|
- (Fill this out as you fix issues and develop your features).
|
||||||
|
- Fixed a bug that made the queryset drop the read_preference after clone().
|
||||||
|
|
||||||
Changes in 0.20.0
|
Changes in 0.20.0
|
||||||
=================
|
=================
|
||||||
|
@ -800,6 +800,7 @@ class BaseQuerySet:
|
|||||||
"_snapshot",
|
"_snapshot",
|
||||||
"_timeout",
|
"_timeout",
|
||||||
"_read_preference",
|
"_read_preference",
|
||||||
|
"_read_concern",
|
||||||
"_iter",
|
"_iter",
|
||||||
"_scalar",
|
"_scalar",
|
||||||
"_as_pymongo",
|
"_as_pymongo",
|
||||||
@ -1324,10 +1325,11 @@ class BaseQuerySet:
|
|||||||
final_pipeline = initial_pipeline + user_pipeline
|
final_pipeline = initial_pipeline + user_pipeline
|
||||||
|
|
||||||
collection = self._collection
|
collection = self._collection
|
||||||
if self._read_preference is not None:
|
if self._read_preference is not None or self._read_concern is not None:
|
||||||
collection = self._collection.with_options(
|
collection = self._collection.with_options(
|
||||||
read_preference=self._read_preference
|
read_preference=self._read_preference, read_concern=self._read_concern
|
||||||
)
|
)
|
||||||
|
|
||||||
return collection.aggregate(final_pipeline, cursor={}, **kwargs)
|
return collection.aggregate(final_pipeline, cursor={}, **kwargs)
|
||||||
|
|
||||||
# JS functionality
|
# JS functionality
|
||||||
|
@ -4053,6 +4053,32 @@ class TestQueryset(unittest.TestCase):
|
|||||||
|
|
||||||
Number.drop_collection()
|
Number.drop_collection()
|
||||||
|
|
||||||
|
def test_clone_retains_settings(self):
|
||||||
|
"""Ensure that cloning retains the read_preference and read_concern
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Number(Document):
|
||||||
|
n = IntField()
|
||||||
|
|
||||||
|
Number.drop_collection()
|
||||||
|
|
||||||
|
qs = Number.objects
|
||||||
|
qs_clone = qs.clone()
|
||||||
|
assert qs._read_preference == qs_clone._read_preference
|
||||||
|
assert qs._read_concern == qs_clone._read_concern
|
||||||
|
|
||||||
|
qs = Number.objects.read_preference(ReadPreference.PRIMARY_PREFERRED)
|
||||||
|
qs_clone = qs.clone()
|
||||||
|
assert qs._read_preference == ReadPreference.PRIMARY_PREFERRED
|
||||||
|
assert qs._read_preference == qs_clone._read_preference
|
||||||
|
|
||||||
|
qs = Number.objects.read_concern({"level": "majority"})
|
||||||
|
qs_clone = qs.clone()
|
||||||
|
assert qs._read_concern.document == {"level": "majority"}
|
||||||
|
assert qs._read_concern == qs_clone._read_concern
|
||||||
|
|
||||||
|
Number.drop_collection()
|
||||||
|
|
||||||
def test_using(self):
|
def test_using(self):
|
||||||
"""Ensure that switching databases for a queryset is possible
|
"""Ensure that switching databases for a queryset is possible
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user