Skip to content

Commit 2d5ddce

Browse files
committed
Minor read pref updates
Add read prefs to aggregate method Pop all extra read pref kwargs
1 parent 11c3f3a commit 2d5ddce

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

pymongo/collection.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,10 @@ def find(self, *args, **kwargs):
592592
593593
.. note:: The `max_scan` parameter requires server
594594
version **>= 1.5.1**
595-
595+
596596
.. versionadded:: 2.2.1+
597597
The `tag_sets` and `secondary_acceptable_latency_ms` parameters.
598-
598+
599599
.. versionadded:: 1.11+
600600
The `await_data`, `partial`, and `manipulate` parameters.
601601
@@ -928,10 +928,13 @@ def aggregate(self, pipeline):
928928

929929
return self.__database.command("aggregate", self.__name,
930930
pipeline=pipeline,
931+
read_preference=self.read_preference,
932+
tag_sets=self.tag_sets,
933+
secondary_acceptable_latency_ms=(
934+
self.secondary_acceptable_latency_ms),
931935
slave_okay=self.slave_okay,
932936
_use_master=use_master)
933937

934-
935938
# TODO key and condition ought to be optional, but deprecation
936939
# could be painful as argument order would have to change.
937940
def group(self, key, condition, initial, reduce, finalize=None):

pymongo/database.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,16 @@ def command(self, command, value=1,
368368
'_uuid_subtype': uuid_subtype
369369
}
370370

371-
if not must_use_master:
372-
extra_opts['read_preference'] = kwargs.pop(
373-
'read_preference',
374-
self.read_preference)
375-
extra_opts['tag_sets'] = kwargs.pop(
376-
'tag_sets',
377-
self.tag_sets)
378-
extra_opts['secondary_acceptable_latency_ms'] = kwargs.pop(
379-
'secondary_acceptable_latency_ms',
380-
self.secondary_acceptable_latency_ms)
371+
372+
extra_opts['read_preference'] = kwargs.pop(
373+
'read_preference',
374+
self.read_preference)
375+
extra_opts['tag_sets'] = kwargs.pop(
376+
'tag_sets',
377+
self.tag_sets)
378+
extra_opts['secondary_acceptable_latency_ms'] = kwargs.pop(
379+
'secondary_acceptable_latency_ms',
380+
self.secondary_acceptable_latency_ms)
381381

382382
fields = kwargs.get('fields')
383383
if fields is not None and not isinstance(fields, dict):

0 commit comments

Comments
 (0)