|
|
@@ -33,9 +33,16 @@ proto.evaluateInternal = function evaluateInternal(vars){
|
|
|
var product = 1;
|
|
|
for(var i = 0, n = this.operands.length; i < n; ++i){
|
|
|
var value = this.operands[i].evaluateInternal(vars);
|
|
|
- if(value instanceof Date) throw new Error("$multiply does not support dates; code 16375");
|
|
|
- product *= Value.coerceToDouble(value);
|
|
|
+ if (typeof value == "number") {
|
|
|
+ product *= Value.coerceToDouble(value);
|
|
|
+ } else if (value == null || value == undefined) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ throw new Error("$multiply only supports numeric types, not "+typeof value+"; code 16555");
|
|
|
+ }
|
|
|
}
|
|
|
+ //NOTE: DEVIATION FROM MONGO: The c++ code (expressions.cpp line 1659) deals with types that
|
|
|
+ // do not seem to apply to javascript.
|
|
|
if(typeof(product) != "number") throw new Error("$multiply resulted in a non-numeric type; code 16418");
|
|
|
return product;
|
|
|
};
|