summaryrefslogtreecommitdiff
path: root/jstests/core/update_server-12848.js
blob: f5ee9a8f2fa5f2aed8fadf70dccbec88c50c1460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// In SERVER-12848, it was shown that validation fails for certain types of updates
// because the validate code was attempting to validate field names in array. Mutable
// doesn't offer guarantees about the examined field name of array elements, only of the
// field name of array elements when serialized. This is a regression test to
// check that the new validation logic doesn't attempt to validate field names.

var res;
var t = db.update_server_12848;
t.drop();

var orig = { "_id" : 1, "a" : [ 1, [ ] ] };
res = t.insert(orig);
assert.writeOK(res, "insert");
assert.eq(orig, t.findOne());

res = t.update({ "_id" : 1 }, { $addToSet : { "a.1" : 1 } });
assert.writeOK(res, "update");

var updated = { "_id" : 1, "a" : [ 1, [ 1 ] ] };
assert.eq(updated, t.findOne());