ReadPreferable clobbers flags

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Critical - P2
    • 2.0.5
    • Affects Version/s: 2.0.4
    • Component/s: Private API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 (Inactive)
              Reporter:
              Chris Heald
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: