summaryrefslogtreecommitdiff
path: root/jstests/aggregation/variables/runtime_constants.js
blob: 49d305cb4c786dfe5c87bb4637d0b1c2df51d0b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * 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: {}}),
    51144);

// Runtime constant $$JS_SCOPE is unable to be retrieved by users.
assert.commandFailedWithCode(
    db.runCommand(
        {aggregate: coll.getName(), pipeline: [{$addFields: {field: "$$JS_SCOPE"}}], cursor: {}}),
    51144);
})();