Fixed Doc.objects(read_preference=X) not setting read preference (#352)
This commit is contained in:
parent
ceece5a7e2
commit
4c8dfc3fc2
@ -5,6 +5,7 @@ Changelog
|
|||||||
|
|
||||||
Changes in 0.8.2
|
Changes in 0.8.2
|
||||||
================
|
================
|
||||||
|
- Fixed Doc.objects(read_preference=X) not setting read preference (#352)
|
||||||
- Django session ttl index expiry fixed (#329)
|
- Django session ttl index expiry fixed (#329)
|
||||||
- Fixed pickle.loads (#342)
|
- Fixed pickle.loads (#342)
|
||||||
- Documentation fixes
|
- Documentation fixes
|
||||||
|
@ -104,13 +104,17 @@ class QuerySet(object):
|
|||||||
raise InvalidQueryError(msg)
|
raise InvalidQueryError(msg)
|
||||||
query &= q_obj
|
query &= q_obj
|
||||||
|
|
||||||
queryset = self.clone()
|
if read_preference is None:
|
||||||
|
queryset = self.clone()
|
||||||
|
else:
|
||||||
|
# Use the clone provided when setting read_preference
|
||||||
|
queryset = self.read_preference(read_preference)
|
||||||
|
|
||||||
queryset._query_obj &= query
|
queryset._query_obj &= query
|
||||||
queryset._mongo_query = None
|
queryset._mongo_query = None
|
||||||
queryset._cursor_obj = None
|
queryset._cursor_obj = None
|
||||||
if read_preference is not None:
|
|
||||||
queryset.read_preference(read_preference)
|
|
||||||
queryset._class_check = class_check
|
queryset._class_check = class_check
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
|
@ -3098,7 +3098,10 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
self.assertEqual([], bars)
|
self.assertEqual([], bars)
|
||||||
|
|
||||||
self.assertRaises(ConfigurationError, Bar.objects,
|
self.assertRaises(ConfigurationError, Bar.objects,
|
||||||
read_preference='Primary')
|
read_preference='Primary')
|
||||||
|
|
||||||
|
bars = Bar.objects(read_preference=ReadPreference.SECONDARY_PREFERRED)
|
||||||
|
self.assertEqual(bars._read_preference, ReadPreference.SECONDARY_PREFERRED)
|
||||||
|
|
||||||
def test_json_simple(self):
|
def test_json_simple(self):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user