{ "_comment": [ "Inputs only. Expectations are measured -- see record.js.", "`$mul`, `$min` and `$max`. The two comparison operators are not numeric", "at all -- they compare in BSON canonical order, which is why a string", "field and a number operand have a defined answer -- and the cases here", "are shaped to say which of the three rules each one follows." ], "documents": [{ "_id": 1, "a": 5, "s": "b", "d": 2.5 }], "cases": [ { "description": "$mul multiplies an int by an int", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "a": 2 } } } }, { "description": "$mul of a missing field", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "gone": 5 } } } }, { "description": "$mul mixes int and double", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "d": 2 } } } }, { "description": "$mul by zero", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "a": 0 } } } }, { "description": "$mul overflowing an int32", "documents": [{ "_id": 1, "a": 2000000000 }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "a": 2 } } } }, { "description": "$mul of a non-numeric field", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "s": 2 } } } }, { "description": "$mul by a non-numeric operand", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "a": "x" } } } }, { "description": "$mul down a dotted path", "documents": [{ "_id": 1, "n": { "a": 3 } }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "n.a": 4 } } } }, { "description": "$min writes when the operand is lower", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$min": { "a": 3 } } } }, { "description": "$min leaves the field when the operand is higher", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$min": { "a": 7 } } } }, { "description": "$min of a missing field always writes", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$min": { "gone": 7 } } } }, { "description": "$min against a field of another type", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$min": { "s": 5 } } } }, { "description": "$min compares an int and an equal double", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$min": { "a": 5.0 } } } }, { "description": "$max writes when the operand is higher", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$max": { "a": 7 } } } }, { "description": "$max leaves the field when the operand is lower", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$max": { "a": 3 } } } }, { "description": "$max of a missing field always writes", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$max": { "gone": 7 } } } }, { "description": "$max against a field of another type", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$max": { "s": 5 } } } }, { "description": "$max against a null field", "documents": [{ "_id": 1, "a": null }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$max": { "a": 1 } } } }, { "description": "$min and $max on the same field in one update", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$min": { "a": 3 }, "$max": { "a": 9 } } } }, { "description": "$min through an array index", "documents": [{ "_id": 1, "t": [5, 5] }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$min": { "t.0": 1 } } } }, { "description": "$mul through a positional segment", "documents": [{ "_id": 1, "t": [{ "a": 2 }, { "a": 3 }] }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$mul": { "t.$[].a": 10 } } } } ] }