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

$pullAll causes empty embedded object field to be created

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.0.7, 2.2.0-rc0
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • ALL

      This looks like unusual behavior.

      For example with a document like:

      { "_id" : ObjectId("4fd2736696a0c5567029c674"), "x" : 10 }

      Issuing an update with $pullAll on a key that does not exist inside an embedded doc causes the field to be created:

      db.test.update(

      {x:10}

      , {$pullAll : {"test.a" : ["foo", "bar"]}})

      The (empty) embedded object "test" will now exist in the doc:
      > db.test.find()
      { "_id" : ObjectId("4fd2736696a0c5567029c674"), "test" : { }, "x" : 10 }

      I would have expected no change in the document's fields if the $pullAll references a key that does not exist.

            Assignee:
            richard.kreuter Richard Kreuter (Inactive)
            Reporter:
            mikeo@mongodb.com Michael O'Brien
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: