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
|
||||
================
|
||||
- Fixed Doc.objects(read_preference=X) not setting read preference (#352)
|
||||
- Django session ttl index expiry fixed (#329)
|
||||
- Fixed pickle.loads (#342)
|
||||
- Documentation fixes
|
||||
|
@ -104,13 +104,17 @@ class QuerySet(object):
|
||||
raise InvalidQueryError(msg)
|
||||
query &= q_obj
|
||||
|
||||
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._mongo_query = None
|
||||
queryset._cursor_obj = None
|
||||
if read_preference is not None:
|
||||
queryset.read_preference(read_preference)
|
||||
queryset._class_check = class_check
|
||||
|
||||
return queryset
|
||||
|
||||
def __len__(self):
|
||||
|
@ -3100,6 +3100,9 @@ class QuerySetTest(unittest.TestCase):
|
||||
self.assertRaises(ConfigurationError, Bar.objects,
|
||||
read_preference='Primary')
|
||||
|
||||
bars = Bar.objects(read_preference=ReadPreference.SECONDARY_PREFERRED)
|
||||
self.assertEqual(bars._read_preference, ReadPreference.SECONDARY_PREFERRED)
|
||||
|
||||
def test_json_simple(self):
|
||||
|
||||
class Embedded(EmbeddedDocument):
|
||||
|
Loading…
x
Reference in New Issue
Block a user