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

updatedExisting should be set to false when $addToSet doesn't change the list

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.6.5
    • Component/s: None
    • None

      Using $addToSet there is no way to find if the add changed the set. I would have though that the updatedExisting field in getLastError would reflect if a change was made or not but it doesn't seem to do that.

      > db.set.insert(

      { set : ['1','2','3'], _id : "123" }

      );
      > db.set.update({_id:"123"},{"$addToSet":{ set: '4'}}); db.runCommand("getlasterror");

      { "err" : null, "updatedExisting" : true, "n" : 1, "ok" : 1 }

      > db.set.update({_id:"123"},{"$addToSet":{ set: '4'}}); db.runCommand("getlasterror");

      { "err" : null, "updatedExisting" : true, "n" : 1, "ok" : 1 }

            Assignee:
            Unassigned Unassigned
            Reporter:
            bdarfler Benjamin Darfler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: