summaryrefslogtreecommitdiff
path: root/jstests/change_streams
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2019-05-07 16:50:39 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2019-05-10 09:54:51 -0400
commitbf6c2696da7eb207c28e83f5bb7401c97b0f69ac (patch)
tree09becafec6a4c0fde05c809c0fad44669d1684dd /jstests/change_streams
parente5bc443f43e5d7a41e7acafd2c6d9dedc45adfd2 (diff)
downloadmongo-bf6c2696da7eb207c28e83f5bb7401c97b0f69ac.tar.gz
SERVER-40238 New stage alias: $set => $addFields
Diffstat (limited to 'jstests/change_streams')
-rw-r--r--jstests/change_streams/pipeline_cannot_modify_id_field.js30
-rw-r--r--jstests/change_streams/whitelist.js3
2 files changed, 17 insertions, 16 deletions
diff --git a/jstests/change_streams/pipeline_cannot_modify_id_field.js b/jstests/change_streams/pipeline_cannot_modify_id_field.js
index 3db6c0990eb..815dad648ae 100644
--- a/jstests/change_streams/pipeline_cannot_modify_id_field.js
+++ b/jstests/change_streams/pipeline_cannot_modify_id_field.js
@@ -34,30 +34,30 @@
{$project: {_id: {data: "$_id._data", typeBits: "$_id._typeBits"}}}, // Fields renamed.
{$project: {_id: {_typeBits: "$_id._typeBits", _data: "$_id._data"}}}, // Fields reordered.
{$project: {_id: {_data: "$_id._typeBits", _typeBits: "$_id._data"}}}, // Fields swapped.
- {$addFields: {_id: "newValue"}},
- {$addFields: {_id: "$otherField"}},
- {$addFields: {"_id._data": "newValue"}},
- {$addFields: {"_id._data": "$otherField"}},
- {$addFields: {"_id.otherField": "newValue"}}, // New subfield added to _id.
+ {$set: {_id: "newValue"}},
+ {$set: {_id: "$otherField"}},
+ {$set: {"_id._data": "newValue"}},
+ {$set: {"_id._data": "$otherField"}},
+ {$set: {"_id.otherField": "newValue"}}, // New subfield added to _id.
[
{$addFields: {otherField: "$_id"}},
- {$addFields: {otherField: "newValue"}},
- {$addFields: {_id: "$otherField"}}
+ {$set: {otherField: "newValue"}},
+ {$set: {_id: "$otherField"}}
],
[
// Fields renamed.
{$addFields: {newId: {data: "$_id._data", typeBits: "$_id._typeBits"}}},
- {$addFields: {_id: "$newId"}}
+ {$set: {_id: "$newId"}}
],
[
// Fields reordered.
{$addFields: {newId: {_typeBits: "$_id._typeBits", _data: "$_id._data"}}},
- {$addFields: {_id: "$newId"}}
+ {$set: {_id: "$newId"}}
],
[
// Fields swapped.
{$addFields: {newId: {_data: "$_id._typeBits", _typeBits: "$_id._data"}}},
- {$addFields: {_id: "$newId"}}
+ {$set: {_id: "$newId"}}
],
{$replaceRoot: {newRoot: {otherField: "$_id"}}},
{$redact: {$cond: {if: {$gt: ["$_id", {}]}, then: "$$DESCEND", else: "$$PRUNE"}}} // _id:0
@@ -82,13 +82,13 @@
],
{$project: {"_id._data": 1, "_id._typeBits": 1}},
{$project: {_id: {_data: "$_id._data", _typeBits: "$_id._typeBits"}}},
- {$addFields: {_id: "$_id"}},
+ {$set: {_id: "$_id"}},
{$addFields: {otherField: "newValue"}},
- {$addFields: {_id: {_data: "$_id._data", _typeBits: "$_id._typeBits"}}},
- [{$addFields: {otherField: "$_id"}}, {$addFields: {_id: "$otherField"}}],
+ {$set: {_id: {_data: "$_id._data", _typeBits: "$_id._typeBits"}}},
+ [{$addFields: {otherField: "$_id"}}, {$set: {_id: "$otherField"}}],
[
{$addFields: {newId: {_data: "$_id._data", _typeBits: "$_id._typeBits"}}},
- {$addFields: {_id: "$newId"}}
+ {$set: {_id: "$newId"}}
],
{$replaceRoot: {newRoot: {_id: "$_id"}}},
{
@@ -141,4 +141,4 @@
getMoreRes, ErrorCodes.ChangeStreamFatalError, transform);
}, transform);
}
-}()); \ No newline at end of file
+}());
diff --git a/jstests/change_streams/whitelist.js b/jstests/change_streams/whitelist.js
index 12848e1e9e7..16b6ca93145 100644
--- a/jstests/change_streams/whitelist.js
+++ b/jstests/change_streams/whitelist.js
@@ -18,6 +18,7 @@
{$match: {_id: {$exists: true}}},
{$project: {_id: 1}},
{$addFields: {newField: 1}},
+ {$set: {newField: 1}},
{$replaceRoot: {newRoot: {_id: "$_id"}}},
{$redact: "$$DESCEND"}
];
@@ -60,4 +61,4 @@
for (let bannedStage of blacklist) {
assertErrorCode(coll, changeStream.concat(bannedStage), ErrorCodes.IllegalOperation);
}
-}()); \ No newline at end of file
+}());