summaryrefslogtreecommitdiff
path: root/jstests/core/bypass_doc_validation.js
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2019-05-01 08:50:27 -0400
committerJames Wahlin <james@mongodb.com>2019-05-02 12:42:15 -0400
commitd812878c2da9138b31743aab2e5ca813fc6e3f19 (patch)
tree8de16412b4e04e6e17cd3381f0dd0395d0fb9c52 /jstests/core/bypass_doc_validation.js
parent73403440366f6b9efb1c262edf319c7c97a67059 (diff)
downloadmongo-d812878c2da9138b31743aab2e5ca813fc6e3f19.tar.gz
SERVER-40400 Test support for 'bypassDocumentValidation' option in combination with a pipeline-style update
Diffstat (limited to 'jstests/core/bypass_doc_validation.js')
-rw-r--r--jstests/core/bypass_doc_validation.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/jstests/core/bypass_doc_validation.js b/jstests/core/bypass_doc_validation.js
index b3290ef4e04..7017f9541cb 100644
--- a/jstests/core/bypass_doc_validation.js
+++ b/jstests/core/bypass_doc_validation.js
@@ -1,4 +1,6 @@
-// @tags: [does_not_support_stepdowns, requires_non_retryable_commands, requires_fastcount]
+// TODO SERVER-40402: Remove 'assumes_write_concern_unchanged' tag.
+// @tags: [does_not_support_stepdowns, requires_non_retryable_commands, requires_fastcount,
+// assumes_write_concern_unchanged]
/**
* Tests that various database commands respect the 'bypassDocumentValidation' flag:
@@ -144,6 +146,24 @@
});
assert.writeOK(res);
assert.eq(1, coll.count({update: 1}));
+
+ // We restrict testing pipeline-style update to commands as they are not supported for
+ // OP_UPDATE which cannot differentiate between an update object and an array.
+ if (myDb.getMongo().writeMode() === "commands") {
+ res = myDb.runCommand({
+ update: collName,
+ updates: [{q: {}, u: [{$addFields: {pipeline: 1}}]}],
+ bypassDocumentValidation: false
+ });
+ assertFailsValidation(BulkWriteResult(res));
+ assert.eq(0, coll.count({pipeline: 1}));
+ res = assert.commandWorked(myDb.runCommand({
+ update: collName,
+ updates: [{q: {}, u: [{$addFields: {pipeline: 1}}]}],
+ bypassDocumentValidation: true
+ }));
+ assert.eq(1, coll.count({pipeline: 1}));
+ }
}
// Run the test using a normal validator.