File: updateh.js

package info (click to toggle)
mongodb 1%3A2.4.8-2~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 81,908 kB
  • sloc: cpp: 739,744; ansic: 152,098; sh: 13,810; python: 11,864; makefile: 1,011; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (30 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (3)
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 )