Skip to content

Commit

Permalink
Allow secondary usage on m/r with inline output. [ fix #2584 ]
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Dec 1, 2012
1 parent 48a1c71 commit 75cd2fb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,12 @@ For instructions on upgrading to newer versions, visit

### Resolved Issues

* \#2584 Allow map/reduce to operate on secondaries if output is set to `inline`.

## 3.0.14

### Resolved Issues

* \#2575 Prevent end of month times from rounding up since floats are not
precise enough to handle usec. (Steve Valaitis)

Expand Down
22 changes: 21 additions & 1 deletion lib/mongoid/contextual/map_reduce.rb
Expand Up @@ -286,7 +286,27 @@ def output_collection
# @since 3.0.0
def results
raise Errors::NoMapReduceOutput.new(command) unless command[:out]
@results ||= session.with(consistency: :strong).command(command)
@results ||= __session__.command(command)
end

# Get the session with the proper consistency.
#
# @api private
#
# @note We can use eventual if the output is set to inline.
#
# @example Get the session.
# map_reduce.__session__
#
# @return [ Session ] The session with consistency set.
#
# @since 3.0.15
def __session__
if command[:out][:inline] != 1
session.with(consistency: :strong)
else
session
end
end
end
end
Expand Down

0 comments on commit 75cd2fb

Please sign in to comment.