-
Type: Task
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
shruti-sridhar has created PR #1745: PYTHON-4550 Add MongoClient.bulkWrite API in mongo-python-driver
Issue Text:
-
- Summary
This PR implements the `MongoClient.bulkWrite` API described in this [spec](https://github.com/mongodb/specifications/blob/master/source/crud/bulk-write.md). This API allows users to perform insert, update, and delete operations against mixed namespaces and receive detailed results for each operation performed.
This new API is distinct from `MongoCollection.bulkWrite` in that it supports writes across many namespaces, and it uses the `bulkWrite` server command rather than individual `insert`/`update`/`delete` server commands.
-
- Major Changes
-
-
- In `pymongo/asynchronous` and `pymongo/synchronous`:
-
- `mongo_client.py`: contains the user-facing `bulk_write()` function
- `client_bulk.py`: contains the `_AsyncClientBulk`/`_ClientBulk` class, which handles the internal details of parsing the input write models, sending batches of commands to the server, handling the response, and returning the result
-
-
- In `pymongo`:
-
- `client_bulk_shared.py`: contains the `ClientBulkWriteException` class and a helper to merge results across batches
- `message.py`: contains the `_ClientBulkWriteContext` class and associated functions to construct and send OP_MSG
- the batch-splitting logic is in the function `_client_batched_op_msg_impl()`
- the OP_MSG construction logic is in the function `_client_construct_op_msg()`
- `operations.py`: contains the write model classes
- `results.py`: contains the `ClientBulkWriteResult` class as well as individual write result classes
-
- Testing
All the added JSON files in this PR are spec tests that were synced from [this commit](https://github.com/mongodb/specifications/commit/10919c92cb784e9730551841e57541bee2e1af93). The unified test runner `test/unified_format.py` contains the changes required for these spec tests to run.
The prose tests from that commit are implemented in `test/asynchronous/test_client_bulk_write.py` and `test/test_client_bulk_write.py`.
- duplicates
-
PYTHON-4550 Add MongoClient.bulk_write API
- Closed