lib/mongo/collection/view/readable.rb in mongo-2.11.4 vs lib/mongo/collection/view/readable.rb in mongo-2.11.5
- old
+ new
@@ -183,10 +183,12 @@
pipeline = [:'$match' => filter]
pipeline << { :'$skip' => opts[:skip] } if opts[:skip]
pipeline << { :'$limit' => opts[:limit] } if opts[:limit]
pipeline << { :'$group' => { _id: 1, n: { :'$sum' => 1 } } }
- opts.select! { |k, _| [:hint, :max_time_ms, :read, :collation, :session].include?(k) }
+ opts = opts.select { |k, _| [:hint, :max_time_ms, :read, :collation, :session].include?(k) }
+ opts[:collation] ||= collation
+
first = aggregate(pipeline, opts).first
return 0 unless first
first['n'].to_i
end