Details
-
Bug
-
Resolution: Done
-
Major - P3
-
2.2.2, 2.3.2
-
None
-
ALL
Description
Mod::isIndexed still fails to correctly determine if a Mod is indexed with certain indices and fieldNames.
This was originally addressed in SERVER-7511 but missed below edge cases:
// case 1: a.0.b
|
t = db.jstests_update_arraymatch8;
|
t.drop();
|
t.ensureIndex( {'a.0.b': 1} ); |
t.insert( {'a': [ [ { b:'old' } ] ] } ); |
assert( t.findOne({'a.0.0.b': 'old'}) ); |
assert( t.findOne({'a.0.b': 'old'}) ); |
t.update( {}, {$set: {'a.0.0.b': 'new'}} ); |
assert( t.findOne({'a.0.b': 'new'}) ); |
assert( !t.findOne({'a.0.b': 'old'}) ); |
|
|
// case 2: a.0.b.c
|
t = db.jstests_update_arraymatch8;
|
t.drop();
|
t.ensureIndex( {'a.0.b.c': 1} ); |
t.insert( {'a': [ { b:[ { c:'old' } ] } ] } ); |
assert( t.findOne({'a.0.b.0.c': 'old'}) ); |
assert( t.findOne({'a.b.0.c': 'old'}) ); |
assert( t.findOne({'a.0.b.c': 'old'}) ); |
assert( t.findOne({'a.b.c': 'old'}) ); |
t.update( {}, {$set: {'a.0.b.0.c': 'new'}} ); |
assert( t.findOne({'a.0.b.c': 'new'}) ); |
assert( !t.findOne({'a.0.b.c': 'old'}) ); |
|
|
// case 3: a.b.$ref
|
t = db.jstests_update_arraymatch8;
|
t.drop();
|
t.ensureIndex( {'a.b.$ref': 1} ); |
t.insert( {'a': [ { 'b':{ '$ref':'old', '$id':0 } } ] } ); |
assert( t.findOne({'a.b.$ref': 'old'}) ); |
assert( t.findOne({'a.0.b.$ref': 'old'}) ); |
t.update( {}, {$set: {'a.0.b.$ref': 'new'}} ); |
assert( t.findOne({'a.b.$ref': 'new'}) ); |
assert( !t.findOne({'a.b.$ref': 'old'}) ); |
|
|
// case 4: a.b and a-b
|
t = db.jstests_update_arraymatch8;
|
t.drop();
|
t.ensureIndex( {'a.b': 1} ); |
t.ensureIndex( {'a-b': 1} ); |
t.insert( {'a':{'b':'old'}} ); |
assert( t.findOne({'a.b': 'old'}) ); |
t.update( {}, {$set: {'a': {'b': 'new'}}} ); |
assert( t.findOne({'a.b': 'new'}) ); |
assert( !t.findOne({'a.b': 'old'}) ); |
Both 2.2.3-rc0 and 2.3.2 currently fail on these tests.
We should also:
- Fix this out of bounds std::string read
if ( ! isdigit( fullName[i+1] ) )continue; - Audit isIndexed for any other problems.
Attachments
Issue Links
- is related to
-
SERVER-7511 update code does not properly determine if a positional mod is indexed, fix Mod::isIndexed()
-
- Closed
-