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

positional operator and $set with an indexed field, update fails with error: can't append to array using string field name

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • Environment:
      win7 x64

      Wed Apr 21 22:34:00 Mongo DB : starting : pid = 0 port = 27333 dbpath = d:/mongodb/data master = 0 slave = 0 64-bit
      ****
      WARNING: This is development version of MongoDB. Not recommended for production.
      ****
      Wed Apr 21 22:34:00 db version v1.5.1-pre-, pdfile version 4.5
      Wed Apr 21 22:34:00 git version: f528f30c4fb604600f24d227c1c57e5c7bbfd191
      Wed Apr 21 22:34:00 sys info: windows (6, 0, 6002, 2, 'Service Pack 2') BOOST_LIB_VERSION=1_39

      > db.test.drop()
      true
      > db.test.insert({a: [

      {id: 1, x: [5,6,7]}

      ,

      {id: 2, x: [8,9,10]}

      ]})
      > db.test.update(

      {'a.id': 1}

      , {$set: {'a.$.x': [1,1,1]}})
      > db.test.find()
      { "_id" : ObjectId("4bcfc3e47c39000000001d80"), "a" : [

      { "id" : 1, "x" : [ 1, 1, 1 ] }

      ,

      { "id" : 2, "x" : [ 8, 9, 10 ] }

      ] }
      > db.test.ensureIndex(

      {'a.id': 1}

      )
      > db.test.update(

      {'a.id': 1}

      , {$set: {'a.$.x': [1,2,2]}})
      can't append to array using string field name
      > db.test.dropIndex(

      {'a.id': 1}

      )

      { "nIndexesWas" : 2, "ok" : 1 }

      > db.test.update(

      {'a.id': 1}

      , {$set: {'a.$.x': [6,6,7]}})
      > db.test.find()
      { "_id" : ObjectId("4bcfc3e47c39000000001d80"), "a" : [

      { "id" : 1, "x" : [ 6, 6, 7 ] }

      ,

      { "id" : 2, "x" : [ 8, 9, 10 ] }

      ] }
      >

            Assignee:
            aaron Aaron Staple
            Reporter:
            toothrot michael haraburda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: