Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3843

map_reduce queries wrong database for results if `out: { db: }` option is specified

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0
    • Affects Version/s: None
    • Component/s: None

      MongoDB and Mongoid allows settings the output of a MR operation, including the database that the MR operation should write to.

      Mongoid subsequently queries the database of the collection that the MR operation was performed on and not the database where the results were written.

      # will always return 0 and not query other.bar
      Foo.map_reduce(map, reduce).out({ replace: 'bar', db: 'other' }).count
      

      The session used to query the results should take the out argument into consideration along the lines of session.with(database: out[:db]) instead of just using the session object that comes with Mongoid::Command.

            Assignee:
            Unassigned Unassigned
            Reporter:
            rgabo Gabor Ratky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: