-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Fully Compatible
-
ALL
-
Integration 2016-09-19
Value::integral() is meant to return true only if it is a numeric value, which has no additional decimal places, and can be represented in 32 bits, e.g. 2, 2.0, or Decimal(2.0), but not (1LL << 42), 2.3, or Decimal128(2.3).
This impacts expressions which require integral arguments, such as $arrayElemAt:
> db.foo.aggregate([{$project: {a: {$arrayElemAt: [[1,2,3], NumberDecimal(2.3)]}}}]) { "_id" : ObjectId("57756385ffcefbf178fce217"), "a" : 3 }
I think this can be fixed by simply switching this line to use toIntExact() instead of toInt().