Files
mongo/jstests/core/query/coercetobool_invalid.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

23 lines
536 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",
);