2012-03-16 20:34:29 -07:00
|
|
|
// 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() {
|
2014-02-02 11:21:12 -05:00
|
|
|
t.remove({});
|
2016-03-09 12:17:50 -05:00
|
|
|
t.save({a: [{b: 'match', count: 0}]});
|
|
|
|
|
t.update({'a.b': 'match'}, {$inc: {'a.$.count': 1}});
|
2012-03-16 20:34:29 -07:00
|
|
|
// Check that the positional $inc succeeded.
|
2016-03-09 12:17:50 -05:00
|
|
|
assert(t.findOne({'a.count': 1}));
|
2012-03-16 20:34:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
testPositionalInc();
|
|
|
|
|
|
|
|
|
|
// Now check with a non multikey index.
|
2016-03-09 12:17:50 -05:00
|
|
|
t.ensureIndex({'a.b': 1});
|
2012-03-16 20:34:29 -07:00
|
|
|
testPositionalInc();
|