Skip to content

Commit ef412a0

Browse files
committed
PYTHON-2554 Stop sending $readPreference primary because it's the server default
1 parent 627dc35 commit ef412a0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pymongo/message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,9 @@ def _op_msg(flags, command, dbname, read_preference, secondary_ok, check_keys,
579579
# getMore commands do not send $readPreference.
580580
if read_preference is not None and "$readPreference" not in command:
581581
if secondary_ok and not read_preference.mode:
582-
command["$readPreference"] = (
583-
ReadPreference.PRIMARY_PREFERRED.document)
584-
else:
582+
read_preference = ReadPreference.PRIMARY_PREFERRED
583+
# Only send $readPreference if it's not primary (the default).
584+
if read_preference.mode:
585585
command["$readPreference"] = read_preference.document
586586
name = next(iter(command))
587587
try:

0 commit comments

Comments
 (0)