Skip to content

Commit eb42bc3

Browse files
authored
PYTHON-5782 Coverage increase, remove old code in message.py (#2772)
1 parent fa3c077 commit eb42bc3

2 files changed

Lines changed: 453 additions & 9 deletions

File tree

pymongo/message.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,6 @@ def _convert_write_result(
171171
elif operation == "update":
172172
if "upserted" in result:
173173
res["upserted"] = [{"index": 0, "_id": result["upserted"]}]
174-
# Versions of MongoDB before 2.6 don't return the _id for an
175-
# upsert if _id is not an ObjectId.
176-
elif result.get("updatedExisting") is False and affected == 1:
177-
# If _id is in both the update document *and* the query spec
178-
# the update document _id takes precedence.
179-
update = command["updates"][0]
180-
_id = update["u"].get("_id", update["q"].get("_id"))
181-
res["upserted"] = [{"index": 0, "_id": _id}]
182174
return res
183175

184176

@@ -660,7 +652,7 @@ def _raise_document_too_large(operation: str, doc_size: int, max_size: int) -> N
660652
else:
661653
# There's nothing intelligent we can say
662654
# about size for update and delete
663-
raise DocumentTooLarge(f"{operation!r} command document too large")
655+
raise DocumentTooLarge(f"{operation} command document too large")
664656

665657

666658
# From the Client Side Encryption spec:

0 commit comments

Comments
 (0)