-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 7.0.4
-
Component/s: Query
-
Environment:Ruby 2.5.0, Rails 5.2.3
-
Fully Compatible
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
- clones
-
MONGOID-4755 Mongoid::Contextual::Aggregable::Mongo#sum does not return nil as expected for Mongoid::Document#none
- Closed
- depends on
-
MONGOID-5147 Add missing find_first & one methods to Mongoid::Contextual::None
- Closed
- links to