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

FSBucket read_preference can return Hash or BSON::Document

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.15.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Minor Change

      FSBucket's read_preference method is currently written as follows:

            def read_preference
              @read_preference ||= options[:read] || database.read_preference
            end
      

      options[:read] is a Hash, database.read_preference is a BSON::Document. Thus depending on what value is passed into constructor of FSBucket, the value returned from read_preference may change type.

      The docstring is also incorrect on the constructor claiming :read option is a string (it is actually a Hash), and on read_preference method claiming to return the preference as a ServerSelector object (the return value is either a Hash or a BSON::Document).

      For consistency with client and database objects let's change FSBucket to return read preference always as a BSON::Document. Unfortunately this is an incompatible change.

      The same issue affects Grid::FSBucket::Stream::Read.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: