Co-authored-by: Gregory Noma <gregory.noma@gmail.com> Co-authored-by: Alyssa Clark <alyssa.clark@mongodb.com> Co-authored-by: Thomas Goyne <thomas.goyne@mongodb.com> Co-authored-by: Philip Stoev <philip.stoev@mongodb.com> Co-authored-by: Joan Bruguera Micó (at MongoDB) <joan.bruguera-mico@mongodb.com> Co-authored-by: Matthew Boros <mattBoros@users.noreply.github.com> Co-authored-by: Finley Lau <finley.lau@mongodb.com> Co-authored-by: Daniel Moody <dmoody256@gmail.com> Co-authored-by: Ted Tuckman <TedTuckman@users.noreply.github.com> Co-authored-by: Yuhong Zhang <yuhong.zhang@mongodb.com> Co-authored-by: Copilot <copilot@github.com> GitOrigin-RevId: 0a318ad31b0a7881549f93fb6bc0dd4cb57934e3
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
/**
|
|
* Tests dropping the system.js collection.
|
|
*
|
|
* @tags: [
|
|
* assumes_read_preference_unchanged,
|
|
* assumes_unsharded_collection,
|
|
* requires_fcv_62,
|
|
* requires_non_retryable_writes,
|
|
* # Uses $where operator.
|
|
* requires_scripting,
|
|
* requires_system_dot_js_stored_functions,
|
|
* # system.js stored functions only work for collections that live on the db-primary shard so
|
|
* # we have to make sure it wont be moved anywhere by the balancer
|
|
* assumes_balancer_off,
|
|
* # TODO(SERVER-84158): Try to include this test(s).
|
|
* exclude_from_timeseries_crud_passthrough,
|
|
* # TODO SERVER-116054: Add support for $where.
|
|
* mozjs_wasm_unsupported,
|
|
* ]
|
|
*/
|
|
const testDB = db.getSiblingDB(jsTestName());
|
|
assert.commandWorked(testDB.dropDatabase());
|
|
|
|
const coll = testDB.getCollection("coll");
|
|
const systemJs = testDB.getCollection("system.js");
|
|
|
|
assert.commandWorked(
|
|
coll.insert([
|
|
{name: "Alice", age: 20},
|
|
{name: "Bob", age: 18},
|
|
]),
|
|
);
|
|
|
|
assert.commandWorked(
|
|
systemJs.insert({
|
|
_id: "isTeenager",
|
|
value: function (age) {
|
|
return age >= 13 && age <= 19;
|
|
},
|
|
}),
|
|
);
|
|
|
|
assert.commandWorked(testDB.runCommand({find: coll.getName(), filter: {$where: "isTeenager(this.age)"}}));
|
|
|
|
assert(systemJs.drop());
|
|
|
|
assert.commandFailedWithCode(
|
|
testDB.runCommand({find: coll.getName(), filter: {$where: "isTeenager(this.age)"}}),
|
|
ErrorCodes.JSInterpreterFailure,
|
|
);
|