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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.0.0
    • Component/s: None
    • Labels:

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: