Skip to content

Commit 9b9b85a

Browse files
committed
RUBY-1054 Use primary read pref for command unless in opts
1 parent c2deda1 commit 9b9b85a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/mongo/database.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ def collections
148148
#
149149
# @return [ Hash ] The result of the command execution.
150150
def command(operation, opts = {})
151-
preference = opts[:read] ? ServerSelector.get(client.options.merge(opts[:read])) : read_preference
152-
server = preference.select_server(cluster)
151+
preference = ServerSelector.get(client.options.merge(opts[:read])) if opts[:read]
152+
server = preference ? preference.select_server(cluster) : cluster.next_primary
153153
Operation::Command.new({
154154
:selector => operation,
155155
:db_name => name,

0 commit comments

Comments
 (0)