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

Documentation for read option of Collection#find is incorrect

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Gone away
    • Affects Version/s: 2.4.3
    • Fix Version/s: 2.5.0
    • Component/s: Public API
    • Labels:
      None
    • Environment:
      MRI 2.3

      Description

      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
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: