[SERVER-2757] findAndModify should only return false if there is an error, not missing doc. findAndRemove throws an exception when no record found Created: 14/Mar/11 Updated: 12/Jul/16 Resolved: 04/Apr/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | None |
| Fix Version/s: | 1.9.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Alexander Azarov | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
MongoDB 1.6.5 |
||
| Backwards Compatibility: | Minor Change |
| Participants: |
| Description |
|
findAndRemove throws CommandResult.Failure when no record in the collection found. Problems: 1. Java driver 2.4 returned null in this scenario Test case: https://github.com/alaz/mongo-java-driver/commit/56478bbefdd99fb97a564a449e99772efc08e7b8 |
| Comments |
| Comment by Mathias Stearn [ 04/Apr/11 ] |
|
Only breaks code that requires throwing an exception on missing object. If callers captured the exception and returned null (as the js shell and python driver do) everything will work as it did before. |
| Comment by auto [ 04/Apr/11 ] |
|
Author: {u'login': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}Message: findAndModify command now returns null rather than failing when query doesn't match any objects No change in helpers needed since they were catching the error and returning |
| Comment by Eliot Horowitz (Inactive) [ 14/Mar/11 ] |
|
if (!upsert) { errmsg = "No matching object found"; return false; } |