Files
mongo/jstests/core/query/coercetobool_invalid.js
Sopho Kevlishvili 0a063e80ce SERVER-100617 removed CoerceToBool from optimization of $and expressions to correctly evaluate conditional in $expr (#33021)
Co-authored-by: Hana Pearlman <hana.pearlman@mongodb.com>
GitOrigin-RevId: 16d3fb2b45b12e9ae77c531a6b0a87fa3ef7e5d4
2025-04-10 02:57:49 +00:00

20 lines
560 B
JavaScript

/*
* Tests that coerceToBool is not a valid expression.
*/
const coll = db.expr_invalid;
coll.drop();
assert.commandFailedWithCode(
db.runCommand({find: coll.getName(), filter: {$expr: {$coerceToBool: {$eq: ["$_id", 15]}}}}),
168,
"Unrecognized expression '$coerceToBool'");
assert.commandFailedWithCode(db.runCommand({
aggregate: coll.getName(),
cursor: {},
pipeline: [{$project: {x: {$coerceToBool: {$eq: ["$_id", 15]}}}}]
}),
31325,
"Unknown expression $coerceToBool");