[SERVER-4157] findAndModify throws exception when _id is in the update document and "new":true Created: 26/Oct/11 Updated: 07/Mar/14 Resolved: 18/Sep/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | 1.8.4, 2.0.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Barrie Segal | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | findAndModify | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All |
||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
findAndModify throws exception when _id is in the update document and "new":true Even though an exception is thrown, the document is still inserted. This was generated from http://groups.google.com/group/mongodb-user/browse_thread/thread/00623298f8c04836 To Reproduce in 2.0.1: (This is reproducible in 1.8.4 as well, although the outputs are slightly different. ) > db.test.drop() , "update" : { "_id" : 2, "name" : "Object 2" }, "upsert" : true } ) , }, > db.runCommand({findAndModify:"test", "query" : { "name" : "asdf" }, "update" : { "_id" : 3, "name" : "Object 3" }, "upsert" : true, "new":true } ) , Adding a value (any value) to the _id key in the query document prevents an exception from being thrown. , "update" : { "_id" : 4, "name" : "Object 4" }, "upsert" : true, "new":true } ) , }, , "update" : { "_id" : 5, "name" : "Object 5" }, "upsert" : true, "new":true } ) , , , "update" : { "_id" : 6, "name" : "Object 6" }, "upsert" : true, "new":true } ) , , |