From d7f1a00285834946ec17bf1e87e3f0a9733ec0e9 Mon Sep 17 00:00:00 2001 From: Tim Taplin Date: Tue, 29 Sep 2026 09:10:40 -0500 Subject: [PATCH] Fix update(updates:) reporting success as failure off server ID 1 mongoc_bulk_operation_execute returns the ID of the server that ran the write, or 0 on failure. update(updates:) compared the result to 1, so a successful bulk update reported an error whenever the server's ID wasn't 1, as is common on replica sets and Atlas. Check for non-zero, as insert(documents:) already does. Originally reported and fixed in #28. Co-Authored-By: Mike Pollard Co-Authored-By: Claude Opus 5.5 --- Sources/PerfectMongoDB/MongoCollection.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/PerfectMongoDB/MongoCollection.swift b/Sources/PerfectMongoDB/MongoCollection.swift index 99cac09..3869a19 100644 --- a/Sources/PerfectMongoDB/MongoCollection.swift +++ b/Sources/PerfectMongoDB/MongoCollection.swift @@ -396,7 +396,7 @@ public class MongoCollection { return Result.fromError(error) } } - guard mongoc_bulk_operation_execute(bulk, toOpaque(&reply), &error) == 1 else { + guard mongoc_bulk_operation_execute(bulk, toOpaque(&reply), &error) != 0 else { return Result.fromError(error) } return .success