lib/mongo/collection/view/map_reduce.rb in mongo-2.12.4 vs lib/mongo/collection/view/map_reduce.rb in mongo-2.13.0.beta1

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (C) 2014-2019 MongoDB, Inc. +# Copyright (C) 2014-2020 MongoDB Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -223,11 +223,14 @@ def initial_query_op(session) Operation::MapReduce.new(map_reduce_spec(session)) end def valid_server?(server) - server.standalone? || server.mongos? || server.primary? || secondary_ok? + description = server.with_connection do |connection| + connection.description + end + description.standalone? || description.mongos? || description.primary? || secondary_ok? end def secondary_ok? out.respond_to?(:keys) && out.keys.first.to_s.downcase == INLINE end @@ -249,11 +252,11 @@ def find_command_spec(session) Builder::MapReduce.new(map_function, reduce_function, view, options.merge(session: session)).command_specification end def fetch_query_op(server, session) - if server.features.find_command_enabled? + if server.with_connection { |connection| connection.features }.find_command_enabled? Operation::Find.new(find_command_spec(session)) else Operation::Find.new(fetch_query_spec) end end @@ -261,10 +264,10 @@ def send_fetch_query(server, session) fetch_query_op(server, session).execute(server, client: client) end def validate_collation!(server) - if (view.options[:collation] || options[:collation]) && !server.features.collation_enabled? + if (view.options[:collation] || options[:collation]) && !server.with_connection { |connection| connection.features }.collation_enabled? raise Error::UnsupportedCollation.new end end end end