~ubuntu-branches/ubuntu/trusty/mongodb/trusty-proposed

« back to all changes in this revision

Viewing changes to jstests/update4.js

  • Committer: Bazaar Package Importer
  • Author(s): Antonin Kral
  • Date: 2010-01-29 19:48:45 UTC
  • Revision ID: james.westby@ubuntu.com-20100129194845-8wbmkf626fwcavc9
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
f = db.jstests_update4;
 
2
f.drop();
 
3
 
 
4
getLastError = function() {
 
5
    ret = db.runCommand( { getlasterror : 1 } );
 
6
//    printjson( ret );
 
7
    return ret;
 
8
}
 
9
 
 
10
f.save( {a:1} );
 
11
f.update( {a:1}, {a:2} );
 
12
assert.eq( true, getLastError().updatedExisting , "A" );
 
13
assert.eq( 1, getLastError().n , "B" );
 
14
f.update( {a:1}, {a:2} );
 
15
assert.eq( false, getLastError().updatedExisting , "C" );
 
16
assert.eq( 0, getLastError().n , "D" );
 
17
 
 
18
f.update( {a:1}, {a:1}, true );
 
19
assert.eq( false, getLastError().updatedExisting , "E" );
 
20
assert.eq( 1, getLastError().n , "F" );
 
21
f.update( {a:1}, {a:1}, true );
 
22
assert.eq( true, getLastError().updatedExisting , "G" );
 
23
assert.eq( 1, getLastError().n , "H" );
 
24
assert.eq( true, db.getPrevError().updatedExisting , "I" );
 
25
assert.eq( 1, db.getPrevError().nPrev , "J" );
 
26
 
 
27
f.findOne();
 
28
assert.eq( undefined, getLastError().updatedExisting , "K" );
 
29
assert.eq( true, db.getPrevError().updatedExisting , "L" );
 
30
assert.eq( 2, db.getPrevError().nPrev , "M" );
 
31
 
 
32
db.forceError();
 
33
assert.eq( undefined, getLastError().updatedExisting , "N" );