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

Documentation for read option of Collection#find is incorrect

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.0
    • Affects Version/s: 2.4.3
    • Component/s: Public API
    • None
    • Environment:
      MRI 2.3

      The rdoc for Collection#find has

      @option opts [:primary, :secondary] :read The default read preference for queries
          #   initiates from this connection object. If +:secondary+ is chosen, reads will be sent
          #   to one of the closest available secondary nodes. If a secondary node cannot be located, the
          #   read will be sent to the primary. If this option is left unspecified, the value of the read
          #   preference for this Collection object will be used.
      
      

      However the code seems to expect that a server selector is passed, as snippets like

      database['some_collection'].find({},{read: {mode: :secondary}}).first
      

      raises the following error

      NoMethodError: undefined method `select_server' for {"mode"=>:secondary}:BSON::Document
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            fcheung Frederick Cheung
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: