blob: 454dd3e9e4e01b8b3a294eae7658268d61806b65 (
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
27
28
29
30
31
32
33
34
35
36
37
38
|
/**
* Test that the $changeStream stage cannot be used in a $lookup pipeline or sub-pipeline.
*
* @tags: [
* change_stream_does_not_expect_txns,
* ]
*/
(function() {
"use strict";
load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
load("jstests/libs/collection_drop_recreate.js"); // For assert[Drop|Create]Collection.
const coll = assertDropAndRecreateCollection(db, "change_stream_ban_from_lookup");
const foreignColl = "unsharded";
assert.commandWorked(coll.insert({_id: 1}));
// Verify that we cannot create a $lookup using a pipeline which begins with $changeStream.
assertErrorCode(
coll, [{$lookup: {from: foreignColl, as: 'as', pipeline: [{$changeStream: {}}]}}], 51047);
// Verify that we cannot create a $lookup if its pipeline contains a sub-$lookup whose pipeline
// begins with $changeStream.
assertErrorCode(
coll,
[{
$lookup: {
from: foreignColl,
as: 'as',
pipeline: [
{$match: {_id: 1}},
{$lookup: {from: foreignColl, as: 'subas', pipeline: [{$changeStream: {}}]}}
]
}
}],
51047);
})();
|