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

map_reduce changes broke read preference passing from Mongoid

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.16.2, 2.17.1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible

      In 2d9f0217ec904a1952a1ada2136502eefbca562e (RUBY-2220) the MapReduce builder was changed to specify read preference externally to the command payload itself, so that it could be correctly passed to pre-3.6 servers. Unfortunately this fix broke read preference passing from Mongoid which relied on the MR builder in driver including read preference in the command payload. This affects Mongoid 7.4-stable going back to at least 7.2.0.

      On Mongoid master this was fixed with the following change:

      index afe68fc7a..964537005 100644
      --- a/lib/mongoid/contextual/map_reduce.rb
      +++ b/lib/mongoid/contextual/map_reduce.rb
      @@ -147,7 +147,7 @@ module Mongoid
             def raw
               validate_out!
               cmd = command
      -        opts = { read: cmd.delete(:read) } if cmd[:read]
      +        opts = { read: criteria.options.fetch(:read) } if criteria.options[:read]
               @map_reduce.database.command(cmd, (opts || {}).merge(session: _session)).first
             end
             alias :results :raw
      

      ... in e2c854a9a90f9f19ef6077b4b185aeb319e4b9d7.

            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: