Given the minimal example
class Product include Mongoid::Document flield :price, type: Integer end
I observe
2.5.0 :001 > Product.all.limit(1).sum('price') => 300 2.5.0 :002 > Product.none.sum('price') => "price" # <-- unexpected
I think the intended result by Mongoid authors would be nil as indicated here:
https://github.com/mongodb/mongoid/blob/4350b9167eb6fe34bc93ed44a428557f63fa6c30/lib/mongoid/contextual/aggregable/mongo.rb#L28
- depends on
-
MONGOID-5147 Add missing find_first & one methods to Mongoid::Contextual::None
- Closed
- is cloned by
-
MONGOID-5239 Add Feature Flag: Mongoid::Contextual::Aggregable::Mongo#sum does not return nil as expected for Mongoid::Document#none
- Closed
- links to