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

Update using positional operator fails with indexed query

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.1.1
    • Affects Version/s: 2.1.0
    • Labels:
      None
    • Environment:
      64-bit Windows 7
    • Fully Compatible
    • ALL

      Attempting to perform an update operation using the positional operator and an indexed query fails.

      I have verified that this same example worked under 2.0.0.

      Example: [Starting with an empty database]

      MongoDB shell version: 2.1.0
      ...
      > db.test.save( { ArrayField : [

      { Name : "First", Count : 1 }

      ] } )
      > db.test.update(

      { "ArrayField.Name" : "First" }

      , { $inc :

      { "ArrayField.$.Count" : 1 }

      } )
      > db.test.find()
      { "_id" : ObjectId("4f47b2bb78da8386a67102c7"), "ArrayField" : [

      { "Name" : "First", "Count" : 2 }

      ] }
      > db.test.ensureIndex(

      { "ArrayField.Name" : 1 }

      )
      > db.test.update(

      { "ArrayField.Name" : "First" }

      , { $inc :

      { "ArrayField.$.Count" : 1 }

      } )
      can't append to array using string field name [$]

            Assignee:
            aaron Aaron Staple
            Reporter:
            pmarkert Phillip Markert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: