diff options
author | Kyle Suarez <kyle.suarez@mongodb.com> | 2018-09-14 12:17:07 -0400 |
---|---|---|
committer | Kyle Suarez <kyle.suarez@mongodb.com> | 2018-09-14 13:51:15 -0400 |
commit | 7e8486ba84837a548f2f1470209eb204a42c293a (patch) | |
tree | a867539db74beba9368012efb0229d44f05d6f7b /jstests/core/views | |
parent | 8f9cf06033d7b1e0942c76eecfb69b5eee044ed6 (diff) | |
download | mongo-7e8486ba84837a548f2f1470209eb204a42c293a.tar.gz |
SERVER-35419 $lookup and $facet must inherit constraints from children
By default, $lookup and $facet do not write persistent data and are
allowed in a transaction. However, both stages must inherit the
"strictest" disk use requirement of any stage in their sub-pipelines,
and can only be used in a transaction if each of those pipelines contain
only transaction-compatible stages.
Diffstat (limited to 'jstests/core/views')
-rw-r--r-- | jstests/core/views/views_creation.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/jstests/core/views/views_creation.js b/jstests/core/views/views_creation.js index 68c896118a5..b320fd711ae 100644 --- a/jstests/core/views/views_creation.js +++ b/jstests/core/views/views_creation.js @@ -77,12 +77,24 @@ assert.commandFailedWithCode( viewsDB.runCommand({create: "dollar$", viewOn: "collection", pipeline: pipe}), ErrorCodes.InvalidNamespace); + + // You cannot create a view with a $out stage, by itself or nested inside of a different stage. + const outStage = {$out: "nonExistentCollection"}; + assert.commandFailedWithCode( + viewsDB.runCommand({create: "viewWithOut", viewOn: "collection", pipeline: [outStage]}), + ErrorCodes.OptionNotSupportedOnView); assert.commandFailedWithCode(viewsDB.runCommand({ - create: "viewWithBadPipeline", + create: "viewWithOutInLookup", viewOn: "collection", - pipeline: [{$project: {_id: false}}, {$out: "notExistingCollection"}] + pipeline: [{$lookup: {from: "other", pipeline: [outStage], as: "result"}}] }), ErrorCodes.OptionNotSupportedOnView); + assert.commandFailedWithCode(viewsDB.runCommand({ + create: "viewWithOutInFacet", + viewOn: "collection", + pipeline: [{$facet: {output: [outStage]}}] + }), + 40600); // These test that, when an existing view in system.views is invalid because of a $out in the // pipeline, the database errors on creation of a new view. |