2 Commits
Author SHA1 Message Date
dsql bdfd441641 chore: bump to 1.2.0
Signed-off-by: disqualifier <dev@disqualifier.me>
2026-10-16 04:12:30 -04:00
dsql 4c7d5ff46d fix: a falsy upserted _id counts as a successful upsert
T2-14: update_document(upsert=True) and upsert_document_field returned
bool(matched_count or upserted_id), so an upsert that inserted _id 0, ""
or False reported failure. test matched_count > 0 or upserted_id is not None.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-10-16 04:12:27 -04:00
3 changed files with 6 additions and 6 deletions

No files matched your search

+3 -3
View File
@@ -8,18 +8,18 @@ helpers for the common paths, with a raw escape hatch for everything else.
`requirements.txt`: `requirements.txt`:
``` ```
mongo @ git+ssh://git@git.rethinkstudios.io/rethink-public/mongo.git@v1.0.0 mongo @ git+ssh://git@git.rethinkstudios.io/rethink-public/mongo.git@v1.2.0
``` ```
Direct: Direct:
```bash ```bash
pip install "mongo @ git+ssh://git@git.rethinkstudios.io/rethink-public/mongo.git@v1.0.0" pip install "mongo @ git+ssh://git@git.rethinkstudios.io/rethink-public/mongo.git@v1.2.0"
``` ```
Requires `motor` and `pymongo` (pulled transitively). Requires `motor` and `pymongo` (pulled transitively).
Drop the `@v1.0.0` suffix from the line above to install the latest unpinned. Drop the `@v1.2.0` suffix from the line above to install the latest unpinned.
## Usage ## Usage
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "mongo" name = "mongo"
version = "1.1.0" version = "1.2.0"
description = "async mongodb wrapper over motor with a raw escape hatch" description = "async mongodb wrapper over motor with a raw escape hatch"
requires-python = ">=3.10" requires-python = ">=3.10"
dependencies = [ dependencies = [
+2 -2
View File
@@ -328,7 +328,7 @@ class MongoDB:
"""replace a whole document, optionally upserting""" """replace a whole document, optionally upserting"""
try: try:
response = await self._db[collection].replace_one(target, document, upsert=upsert) response = await self._db[collection].replace_one(target, document, upsert=upsert)
return bool(response.matched_count or response.upserted_id) return response.matched_count > 0 or response.upserted_id is not None
except Exception: except Exception:
log.exception("db.update_document() on %s", collection) log.exception("db.update_document() on %s", collection)
return False return False
@@ -382,7 +382,7 @@ class MongoDB:
response = await self._db[collection].update_one( response = await self._db[collection].update_one(
target, {"$set": updates}, upsert=True target, {"$set": updates}, upsert=True
) )
return bool(response.matched_count or response.upserted_id) return response.matched_count > 0 or response.upserted_id is not None
except Exception: except Exception:
log.exception("db.upsert_document_field() on %s", collection) log.exception("db.upsert_document_field() on %s", collection)
return False return False