diff options
Diffstat (limited to 'jstests/update_arraymatch7.js')
| -rw-r--r-- | jstests/update_arraymatch7.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/jstests/update_arraymatch7.js b/jstests/update_arraymatch7.js new file mode 100644 index 00000000000..78b025cc9d5 --- /dev/null +++ b/jstests/update_arraymatch7.js @@ -0,0 +1,19 @@ +// Check that the positional operator works properly when an index only match is used for the update +// query spec. SERVER-5067 + +t = db.jstests_update_arraymatch7; +t.drop(); + +function testPositionalInc() { + t.remove(); + t.save( { a:[ { b:'match', count:0 } ] } ); + t.update( { 'a.b':'match' }, { $inc:{ 'a.$.count':1 } } ); + // Check that the positional $inc succeeded. + assert( t.findOne( { 'a.count':1 } ) ); +} + +testPositionalInc(); + +// Now check with a non multikey index. +t.ensureIndex( { 'a.b' : 1 } ); +testPositionalInc(); |
