Skip to content

Commit dc14887

Browse files
DRIVERS-2975 Fix logic for populating BulkWriteException.partialResult (#1665)
1 parent 64c1692 commit dc14887

File tree

3 files changed

+814
-3
lines changed

3 files changed

+814
-3
lines changed

source/crud/bulk-write.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,16 @@ The server's response to `bulkWrite` has the following format:
683683
}
684684
```
685685

686-
If any operations were successful (i.e. `nErrors` is less than the number of operations that were sent), drivers MUST
687-
record the summary count fields in a `BulkWriteResult` to be returned to the user or embedded in a `BulkWriteException`.
688-
Drivers MUST NOT populate the `partialResult` field in `BulkWriteException` if no operations were successful.
686+
Drivers MUST record the summary count fields in a `BulkWriteResult` to be returned to the user or embedded in a
687+
`BulkWriteException` if the response indicates that at least one write was successful:
688+
689+
- For ordered bulk writes, at least one write was successful if `nErrors` is 0 or if the `idx` value for the write error
690+
returned in the results cursor is greater than 0.
691+
- For unordered bulk writes, at least one write was successful if `nErrors` is less than the number of operations that
692+
were included in the `bulkWrite` command.
693+
694+
Drivers MUST NOT populate the `partialResult` field in `BulkWriteException` if it cannot be determined that at least one
695+
write was successfully performed.
689696

690697
Drivers MUST attempt to consume the contents of the cursor returned in the server's `bulkWrite` response before
691698
returning to the user. This is required regardless of whether the user requested verbose or summary results, as the
@@ -859,6 +866,8 @@ batch-splitting to standardize implementations across drivers and simplify batch
859866

860867
## **Changelog**
861868

869+
- 2024-09-25: Update the `partialResult` population logic to account for ordered bulk writes.
870+
862871
- 2024-09-18: Relax numeric type requirements for indexes.
863872

864873
- 2024-05-17: Update specification status to "Accepted".

0 commit comments

Comments
 (0)