fix: correct wrong success predicates in upsert_document_field and create_documents

upsert_document_field returned False for an idempotent no-op upsert on an
existing document (modified_count=0, upserted_id=None) even though the doc
matched the requested state; switch to matched_count like its update_document_field
and update_document_operator siblings.

create_documents returned 0 on a partial insert_many failure, discarding the
BulkWriteError's nInserted count and inviting callers to retry the whole batch
on a wrongly-reported failure, duplicating documents that had already landed.
Catch BulkWriteError specifically and return e.details['nInserted'].

Bump to v0.1.7.

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
2026-07-02 17:22:31 -04:00
parent 9da851629d
commit 30f0e44097
3 changed files with 24 additions and 7 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "mongo"
version = "0.1.6"
version = "0.1.7"
description = "async mongodb wrapper over motor with a raw escape hatch"
requires-python = ">=3.10"
dependencies = [