Skip to content

Commit a6a7ce5

Browse files
DRIVERS-2975 Fix logic for populating BulkWriteException.partialResult (mongodb#1665)
1 parent 647a6e6 commit a6a7ce5

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
@@ -688,9 +688,16 @@ The server's response to `bulkWrite` has the following format:
688688
}
689689
```
690690

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

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

865872
## **Changelog**
866873

874+
- 2024-09-25: Update the `partialResult` population logic to account for ordered bulk writes.
875+
867876
- 2024-09-18: Relax numeric type requirements for indexes.
868877

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

0 commit comments

Comments
 (0)