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

ReadPreferable clobbers flags

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.0.5
    • Affects Version/s: 2.0.4
    • Component/s: Private API
    • Labels:
      None

      Setting cursor flags on a cursor doesn't result in those flags making it to the query, because ReadPreferable clobbers them in update_options:

      https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/operation/read_preferrable.rb#L33-L41

      My fix preserves any cursor flags that have been set, allowing them to actually make it to the server.

            def update_options(context)
              if context.slave_ok? || (!context.mongos? && read.slave_ok?)
                options.dup.tap do |opts|
                  (opts[:flags] ||= []) << :slave_ok
                end
              else
                options
              end
            end
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            cheald Chris Heald
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: