Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-8173

Mod::isIndexed still not correct for some update edge cases

    • ALL

      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.

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: