[DOCS-4968] findAndModify no longer changes return behavior depending on if a sort was specified Created: 10/Mar/15  Updated: 30/Oct/23  Resolved: 28/Sep/15

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: mongodb-3.0
Fix Version/s: Server_Docs_20231030

Type: Bug Priority: Major - P3
Reporter: Charlie Swanson Assignee: Andrew Aldridge
Resolution: Done Votes: 0
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-17650 findAndModify regression when upserti... Closed
Related
related to DOCS-5489 [SERVER] Comment on: "manual/referenc... Closed
Participants:
Days since reply: 8 years, 20 weeks, 1 day ago

 Description   

The 3.0 docs for findAndModify have a section on the output of the command, and then a subsection with a note. In that note, the last two bullet points no longer apply.
E.g.

> db.foo.drop()
true
> db.runCommand({findAndModify: 'foo', query: {_id: 'doc_with_sort'}, update: {$inc: {i: 1}}, upsert: true, new: false, sort: {_id: -1}})
{
	"value" : null,
	"lastErrorObject" : {
		"updatedExisting" : false,
		"n" : 1,
		"upserted" : 'doc_with_sort'
	},
	"ok" : 1
}
> db.runCommand({findAndModify: 'foo', query: {_id: 'doc_without_sort'}, update: {$inc: {i: 1}}, upsert: true, new: false})
{
	"value" : null,
	"lastErrorObject" : {
		"updatedExisting" : false,
		"n" : 1,
		"upserted" : 'doc_without_sort'
	},
	"ok" : 1
}

Notice both with and without the sort parameter, value is null.



 Comments   
Comment by Githook User [ 29/Sep/15 ]

Author:

{u'username': u'i80and', u'name': u'Andrew Aldridge', u'email': u'i80and@foxquill.com'}

Message: DOCS-4968: findAndModify return document

Signed-off-by: kay <kay.kim@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/648233832207e543171595e03d3e51f2613195c3

Comment by Charlie Swanson [ 18/Mar/15 ]

As SERVER-17650 mentions, we should also update the compatibility notes.

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