diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-06-28 15:27:09 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-06-29 14:14:46 -0400 |
commit | 55921e9df12b71cbfd648c7baf82e1078c46f675 (patch) | |
tree | 5d22cde53886974ab7e07cf91df873f96e7e4053 /jstests/core/update_arrayFilters.js | |
parent | 5811a6ac496c6368e4fc4d9a5c8ed51a8b37833a (diff) | |
download | mongo-55921e9df12b71cbfd648c7baf82e1078c46f675.tar.gz |
SERVER-28764 Create AddToSetNode
Diffstat (limited to 'jstests/core/update_arrayFilters.js')
-rw-r--r-- | jstests/core/update_arrayFilters.js | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/jstests/core/update_arrayFilters.js b/jstests/core/update_arrayFilters.js index b54b981ae4d..fc775ed559f 100644 --- a/jstests/core/update_arrayFilters.js +++ b/jstests/core/update_arrayFilters.js @@ -388,23 +388,16 @@ "update failed for a reason other than using array updates with $currentDate"); // $addToSet. - // TODO SERVER-28764: $addToSet should use the new update implementation. coll.drop(); if (db.getMongo().writeMode() === "commands") { - res = coll.update({_id: 0}, {$addToSet: {"a.$[i]": ["elem"]}}, {arrayFilters: [{i: 0}]}); - assert.writeErrorWithCode(res, ErrorCodes.InvalidOptions); - assert.neq( - -1, - res.getWriteError().errmsg.indexOf("Cannot use array filters with modifier $addToSet"), - "update failed for a reason other than using array filters with $addToSet"); + assert.writeOK(coll.insert({_id: 0, a: [[0], [1]]})); + assert.writeOK(coll.update({_id: 0}, {$addToSet: {"a.$[i]": 2}}, {arrayFilters: [{i: 0}]})); + assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [[0, 2], [1]]}); } - assert.writeOK(coll.insert({_id: 0, a: [[]]})); - res = coll.update({_id: 0}, {$addToSet: {"a.$[]": ["elem"]}}); - assert.writeErrorWithCode(res, 16837); - assert.neq(-1, - res.getWriteError().errmsg.indexOf( - "cannot use the part (a of a.$[]) to traverse the element ({a: [ [] ]})"), - "update failed for a reason other than using array updates with $addToSet"); + coll.drop(); + assert.writeOK(coll.insert({_id: 0, a: [[0], [1]]})); + assert.writeOK(coll.update({_id: 0}, {$addToSet: {"a.$[]": 2}})); + assert.eq(coll.findOne({_id: 0}), {_id: 0, a: [[0, 2], [1, 2]]}); // $pop. // TODO SERVER-28769: $pop should use the new update implementation. |