diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2016-01-27 14:03:46 -0500 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2016-01-29 17:37:34 -0500 |
commit | e40a6da919084cba4b0397c1da21c6ee93e78297 (patch) | |
tree | 3fcf06a181e1efd56338aa030ecc2227830cf527 /src/mongo/db/instance.cpp | |
parent | c532f7c7a970ad92949a0a2c48f36dae6dd3d5b4 (diff) | |
download | mongo-e40a6da919084cba4b0397c1da21c6ee93e78297.tar.gz |
SERVER-21823 Update and findAndModify with {upsert: true} should report nMatched:0 nModified:0 if results in an insert
Diffstat (limited to 'src/mongo/db/instance.cpp')
-rw-r--r-- | src/mongo/db/instance.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 921f507ab00..9333bf79ea5 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -723,7 +723,8 @@ void receivedUpdate(OperationContext* txn, const NamespaceString& nsString, Mess UpdateResult res = UpdateStage::makeUpdateResult(updateStats); // for getlasterror - LastError::get(client).recordUpdate(res.existing, res.numMatched, res.upserted); + size_t nMatchedOrInserted = res.upserted.isEmpty() ? res.numMatched : 1U; + LastError::get(client).recordUpdate(res.existing, nMatchedOrInserted, res.upserted); if (repl::ReplClientInfo::forClient(client).getLastOp() != lastOpAtOperationStart) { // If this operation has already generated a new lastOp, don't bother setting it @@ -784,7 +785,8 @@ void receivedUpdate(OperationContext* txn, const NamespaceString& nsString, Mess UpdateResult res = UpdateStage::makeUpdateResult(updateStats); - LastError::get(client).recordUpdate(res.existing, res.numMatched, res.upserted); + size_t nMatchedOrInserted = res.upserted.isEmpty() ? res.numMatched : 1U; + LastError::get(client).recordUpdate(res.existing, nMatchedOrInserted, res.upserted); if (repl::ReplClientInfo::forClient(client).getLastOp() != lastOpAtOperationStart) { // If this operation has already generated a new lastOp, don't bother setting it |