From 1b6f0099f5b675400d052dd43bff65dd8bd3d002 Mon Sep 17 00:00:00 2001 From: Brian Beggs Date: Mon, 20 Jul 2015 15:17:48 -0400 Subject: [PATCH] matched_count should return a non 0 number if self.upserted_id is not none The case that is incorrect here is that when a document is matched, but the data was the same so the upsert didn't happen. Also not sure here why n wasn't checked first. --- pymongo/results.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymongo/results.py b/pymongo/results.py index 8fb974b9ae..621fa48821 100644 --- a/pymongo/results.py +++ b/pymongo/results.py @@ -111,7 +111,7 @@ def matched_count(self): """The number of documents matched for this update.""" self._raise_if_unacknowledged("matched_count") if self.upserted_id is not None: - return 0 + return 1 return self.__raw_result.get("n", 0) @property