summaryrefslogtreecommitdiff
path: root/jstests/updateh.js
blob: 8f06b8f7f69369b834dc1aebb964176b1ff5e42f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Disallow $ in field names - SERVER-3730

t = db.jstest_updateh
t.drop()

t.insert( {x:1} )

t.update( {x:1}, {$set: {y:1}} ) // ok
e = db.getLastErrorObj()
assert.eq( e.err, null )

t.update( {x:1}, {$set: {$z:1}} ) // not ok
e = db.getLastErrorObj()
assert( e.err != null && e.code == 15896 )

t.update( {x:1}, {$unset: {$z:1}} ) // unset ok to remove bad fields
e = db.getLastErrorObj()
assert.eq( e.err, null )

t.update( {x:1}, {$inc: {$z:1}} ) // not ok
e = db.getLastErrorObj()
assert( e.err != null && e.code == 15896 )

t.update( {x:1}, {$pushAll: {$z:[1,2,3]}} ) // not ok
e = db.getLastErrorObj()
assert( e.err != null && e.code == 15896 )

t.update( {x:1}, {$pushAll: {z:[1,2,3]}} ) // ok
e = db.getLastErrorObj()
assert.eq( e.err, null )