[SERVER-13551] Shell improperly deletes objects Created: 10/Apr/14  Updated: 11/Apr/14  Resolved: 10/Apr/14

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

Type: Bug Priority: Major - P3
Reporter: Charlie Page Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-13354 delete operator in db.collection.find... Closed
Related
Operating System: ALL
Steps To Reproduce:

N = 1000

// create data
db.coll.drop()
for (i = 0; i < N; i++) {
newItem =

{"a":1,"b":2}

;
db.coll.insert(newItem);
}

// update
db.coll.find().forEach(function (obj) {
obj.map =

{ "a":obj.a, "b":obj.b }

;
delete obj.a;
delete obj.b;
db.coll.save(obj);
});
//

// check
db.coll.aggregate( { $group :
{ _id : "$map.a",
totalA :

{ $sum : "$map.b" }

}
});

The output should be 2000, it is 1798 in 2.6.0 and 1800 in 2.4.10.

Participants:

 Description   

The mongo shell deletes objects using delete rather then just delete the reference.



 Comments   
Comment by Kamran K. [ 10/Apr/14 ]

This looks like a duplicate of SERVER-13354, which has an explanation for the behavior: https://jira.mongodb.org/browse/SERVER-13354?focusedCommentId=528613&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-528613

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