Current implementation of $mod in v4.2 doesn't raise an error when the remainder is not a number:
db.xxx.find({a: {$mod: [2,'z']}});
{ "_id" : 2, "a" : 2, "b" : "bar" }
The problem stems from https://github.com/mongodb/mongo/blob/f6690d2a4803b3a316bf8f5ba859af35bd433b9b/src/mongo/db/matcher/expression_parser.cpp#L449
which should be
if (!r.isNumber())
- duplicates
-
SERVER-23664 $mod match expression should raise an error when the remainder is not a number
- Closed