Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-987

read method on View throws undefined method `select_server'

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.1.0
    • Affects Version/s: 2.0.6
    • Component/s: None
    • None

      When I try to use the read method to set the read preference, it does not appear to get translated into a ServerSelector.

      See the following shell session:

      $ STANDALONE=false ruby test.rb
      connecting to replicaset
      /Users/joleary/.rvm/gems/ruby-2.0.0-p643@CS-22855/gems/mongo-2.0.6/lib/mongo/collection/view/iterable.rb:38:in `each': undefined method `select_server' for {:mode=>:secondary}:Hash (NoMethodError)
      	from test.rb:13:in `first'
      	from test.rb:13:in `<main>'
      
      $ ruby test.rb
      connecting to standalone
      /Users/joleary/.rvm/gems/ruby-2.0.0-p643@CS-22855/gems/mongo-2.0.6/lib/mongo/collection/view/iterable.rb:38:in `each': undefined method `select_server' for {:mode=>:secondary}:Hash (NoMethodError)
      	from test.rb:13:in `first'
      	from test.rb:13:in `<main>'
      

      The code is :

      test.rb
      require 'mongo'
      Mongo::Logger.logger.level = Logger::INFO
      def standalone?
        (ENV.has_key?('STANDALONE') && ENV['STANDALONE'] == 'true') || !ENV.has_key?('STANDALONE')
      end
      
      puts "connecting to #{standalone? ? 'standalone' : 'replicaset'}"
      
      config = standalone? ?  {:hosts => ['127.0.0.1:27017'],:options => {:database => 'cookie-store'}} : config = {:hosts => ['127.0.0.1:37017','127.0.0.1:37018','127.0.0.1:37019'],:options => {:database => 'cookie-store', :replica_set => 'replset'}}
      c = Mongo::Client.new(config[:hosts], config[:options])
      # c[:cookie_jar].find.read(:mode=>:primary).first
      
      puts c[:cookie_jar].find.read(:mode=>:primary).first
      

      I tested on 2.0.0 and 2.0.6 (nothing in between).

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            jim.oleary@mongodb.com James O'Leary
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: