Skip to content

Commit 998140a

Browse files
committed
Properly process aggregation options
1 parent 2562ff2 commit 998140a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/mongo/collection/view/aggregation.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class Aggregation
4242
# @since 2.1.0
4343
OPTIONS_MAP = {
4444
:allow_disk_use => :allowDiskUse,
45-
:max_time_ms => :maxTimeMS
45+
:max_time_ms => :maxTimeMS,
46+
:explain => :explain
4647
}
4748

4849
# Set to true if disk usage is allowed during the aggregation.
@@ -104,7 +105,13 @@ def aggregate_spec
104105

105106
def process_options
106107
@agg_options ||= @options.each.reduce({}) do |opts, (key, value)|
107-
OPTIONS_MAP[key] ? opts.merge(OPTIONS_MAP[key] => value) : opts
108+
if OPTIONS_MAP[key]
109+
opts.merge(OPTIONS_MAP[key] => value)
110+
elsif OPTIONS_MAP.values.include?(key)
111+
opts.merge(key => value)
112+
else
113+
opts
114+
end
108115
end
109116
end
110117

0 commit comments

Comments
 (0)