[SERVER-2530] FindAndModify doesn't work if sort is used and _id in query Created: 10/Feb/11  Updated: 12/Jul/16  Resolved: 10/Feb/11

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: 1.7.6

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

> db.testcollection.find()

{ "_id" : 1, "priority" : 2, "inprogress" : false, "name" : "abc" }

> db.runCommand({
... findandmodify : "testcollection",
... query :

{ _id : 1 }

,
... sort :

{ priority : -1 }

,
... update : { $set :

{ inprogress : true, started : Date() }

},
... new : true
... })
{
"value" :

{ "_id" : 1, "priority" : 2, "inprogress" : false, "name" : "abc" }

,
"ok" : 1
}
> db.testcollection.find()

{ "_id" : 1, "priority" : 2, "inprogress" : false, "name" : "abc" }

>



 Comments   
Comment by auto [ 10/Feb/11 ]

Author:

{u'login': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: fix findAndModify when sort is used and _id in query SERVER-2530
https://github.com/mongodb/mongo/commit/3d8ca912a03cb6e6a0ebc431ac72c3b89e87b7be

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