[SERVER-6226] findAndModify return value inconsistent between 2.0.x and 2.1.2 when using upsert Created: 27/Jun/12  Updated: 05/Nov/12  Resolved: 03/Jul/12

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.1.2
Fix Version/s: 2.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Bernie Hackett Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: findAndModify
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Minor Change
Operating System: ALL
Participants:

 Description   

Found this while testing PyMongo against 2.1.2. In 2.0.x mongod returns {'ok': 1.0, 'value': {}}, in 2.1.2 it returns

{'ok': 1.0, 'value': null}

.

MongoDB shell version: 2.0.6
connecting to: test
> db.test.findAndModify({query: {'_id': 1}, update: {'$inc': {'i': 1}}, upsert: true})
{ }
 
MongoDB shell version: 2.1.2
connecting to: test
> db.test.findAndModify({query: {'_id': 1}, update: {'$inc': {'i': 1}}, upsert: true})
null

This will cause problems for code that expects a document as return value.



 Comments   
Comment by auto [ 13/Jul/12 ]

Author:

{u'date': u'2012-07-13T09:52:17-07:00', u'email': u'samk@10gen.com', u'name': u'Sam Kleinman'}

Message: release notes: SERVER-6226 related edits
Branch: master
https://github.com/mongodb/docs/commit/a48f94cb2be61dafba21decb1c2feddd2c1b9756

Comment by auto [ 13/Jul/12 ]

Author:

{u'date': u'2012-07-12T15:46:47-07:00', u'email': u'samk@10gen.com', u'name': u'Sam Kleinman'}

Message: SERVER-6226 adding note about find and modify change to the release notes
Branch: master
https://github.com/mongodb/docs/commit/321e3ed6c592a58643b9c46e85c460a578df4fe5

Comment by auto [ 03/Jul/12 ]

Author:

{u'date': u'2012-07-03T11:06:41-07:00', u'name': u'behackett', u'email': u'bernie@10gen.com'}

Message: Fix test failure due to 2.1.2 behaviour change.

See SERVER-6226 for more information.
Branch: master
https://github.com/mongodb/mongo-python-driver/commit/d21a98aedace2182cf10d4d4d0b5d83b863f91a3

Comment by auto [ 03/Jul/12 ]

Author:

{u'date': u'2012-07-03T10:22:01-07:00', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-6226 - test for new behavior
Branch: master
https://github.com/mongodb/mongo/commit/19b1fafe6e7d934f7aee2192bef139afc8345d41

Comment by Bernie Hackett [ 27/Jun/12 ]

This behavior is new in 2.1.2:

MongoDB shell version: 2.1.2
connecting to: test
> db.version()
2.1.1
>
> db.test.findAndModify({query: {'_id': 1}, update: {'$inc': {'i': 1}}, upsert: true})
{ }

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