mongo/jstests/aggregation/variables/runtime_constants.js

26 lines
704 B
JavaScript

/*
* Tests the behavior of runtime constants $$IS_MR and $$JS_SCOPE.
*/
(function() {
"use strict";
load('jstests/aggregation/extras/utils.js');
const coll = db.runtime_constants;
coll.drop();
assert.commandWorked(coll.insert({x: true}));
// Runtime constant $$IS_MR is unable to be retrieved by users.
assert.commandFailedWithCode(
db.runCommand(
{aggregate: coll.getName(), pipeline: [{$addFields: {testField: "$$IS_MR"}}], cursor: {}}),
17276);
// Runtime constant $$JS_SCOPE is unable to be retrieved by users.
assert.commandFailedWithCode(
db.runCommand(
{aggregate: coll.getName(), pipeline: [{$addFields: {field: "$$JS_SCOPE"}}], cursor: {}}),
17276);
})();