summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2017-10-10 14:45:31 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2017-10-11 09:47:56 -0400
commitb1d1b244c73a726c0c6708cf1cb196079f570414 (patch)
tree111fd7efe4dfa7ff8816604198e60dd323ae0f4d /jstests/core
parentfc249a3d97370dcaa4a6fd8c58f116bfca71283f (diff)
downloadmongo-b1d1b244c73a726c0c6708cf1cb196079f570414.tar.gz
SERVER-31496 MatchExpressionParser::parse() should not throw
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/expr.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/core/expr.js b/jstests/core/expr.js
index d2c6d9216ff..63ffea5e7e4 100644
--- a/jstests/core/expr.js
+++ b/jstests/core/expr.js
@@ -204,6 +204,18 @@
assert.eq(1, writeRes.nRemoved);
assert.writeError(coll.remove({_id: 0, $expr: {$eq: ["$a", "$$unbound"]}}));
+ // Any writes preceding the write that fails to parse are executed.
+ coll.drop();
+ assert.writeOK(coll.insert({_id: 0}));
+ assert.writeOK(coll.insert({_id: 1}));
+ writeRes = db.runCommand({
+ delete: coll.getName(),
+ deletes: [{q: {_id: 0}, limit: 1}, {q: {$expr: "$$unbound"}, limit: 1}]
+ });
+ assert.commandWorked(writeRes);
+ assert.eq(writeRes.writeErrors[0].code, 17276, tojson(writeRes));
+ assert.eq(writeRes.n, 1, tojson(writeRes));
+
//
// $expr in update.
//
@@ -236,4 +248,16 @@
{$set: {"a.$[i].b": 6}},
{arrayFilters: [{"i.b": 5, $expr: {$eq: ["$i.b", 5]}}]}));
}
+
+ // Any writes preceding the write that fails to parse are executed.
+ coll.drop();
+ assert.writeOK(coll.insert({_id: 0}));
+ assert.writeOK(coll.insert({_id: 1}));
+ writeRes = db.runCommand({
+ update: coll.getName(),
+ updates: [{q: {_id: 0}, u: {$set: {b: 6}}}, {q: {$expr: "$$unbound"}, u: {$set: {b: 6}}}]
+ });
+ assert.commandWorked(writeRes);
+ assert.eq(writeRes.writeErrors[0].code, 17276, tojson(writeRes));
+ assert.eq(writeRes.n, 1, tojson(writeRes));
})();