[SERVER-2764] updatedExisting should be set to false when $addToSet doesn't change the list Created: 15/Mar/11  Updated: 29/Aug/11  Resolved: 16/Mar/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.6.5
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Benjamin Darfler Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

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 }

 Comments   
Comment by Eliot Horowitz (Inactive) [ 16/Mar/11 ]

That field is supposed to be true if the update is applied to an existing document, which it is.
The fact that nothing is changed is different.
If you think we should add that as well, can you open a separate ticket.

Generated at Thu Feb 08 03:01:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.