You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## What
This PR makes `create_item` and `upsert_item` require an explicit item
id, matching the pattern already used by `read_item`, `replace_item`,
and `delete_item`.
### Breaking Changes
**`azure_data_cosmos` (SDK):**
- `ContainerClient::create_item()` signature changed from
`(partition_key, item, options)` to `(partition_key, item_id, item,
options)`
- `ContainerClient::upsert_item()` signature changed from
`(partition_key, item, options)` to `(partition_key, item_id, item,
options)`
**`azure_data_cosmos_driver` (internal):**
- `CosmosOperation::create_item()` now takes `ItemReference` instead of
`(ContainerReference, PartitionKey)`
- `CosmosOperation::upsert_item()` now takes `ItemReference` instead of
`(ContainerReference, PartitionKey)`
All five point operations (`create_item`, `upsert_item`, `read_item`,
`replace_item`, `delete_item`) now follow the same pattern in both the
SDK and the driver.
## Why
PR #4128 cut over more point operations to the driver but inadvertently
removed the `ItemReference`-based overloads for `create_item` and
`upsert_item`. This was a regression — the original design requires the
caller to provide the item id explicitly so the driver never needs to
parse the request body to extract the document id. Parsing the body in
the driver is both unnecessary overhead and a layering violation (the
SDK should own serialization concerns).
## How
- **Driver (`cosmos_operation.rs`):** `create_item` and `upsert_item`
factory methods now take `ItemReference` and call
`Self::new(OperationType::Create/Upsert, item)`, identical to
`read_item`/`delete_item`/`replace_item`.
- **Driver (`operation_pipeline.rs`):** `build_transport_request`
detects Create/Upsert Document operations and uses
`compute_feed_paths()` instead of `compute_paths()`, since these
operations POST to the collection feed URL even though the operation
carries the item id.
- **Driver (`cosmos_resource_reference.rs`):** Added
`compute_feed_paths()` to compute feed-style paths (parent URL + signing
link) for references that carry a leaf id.
- **SDK (`container_client.rs`):** `create_item` and `upsert_item` now
accept `item_id: &str` and construct an `ItemReference` before
delegating to the driver.
- All tests, examples, benchmarks, and perf tooling updated.
## Testing
Existing test coverage is sufficient
Copy file name to clipboardExpand all lines: sdk/cosmos/azure_data_cosmos/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@
15
15
16
16
### Breaking Changes
17
17
18
+
-`ContainerClient::create_item()` and `ContainerClient::upsert_item()` now require an `item_id: &str` parameter (same pattern as `replace_item` and `read_item`). The item id is passed to the driver via `ItemReference` so the body never needs to be parsed to extract the document id.
18
19
- Renamed `replace_throughput` to `begin_replace_throughput` on `ContainerClient` and `DatabaseClient`. The return type changed from `ResourceResponse<ThroughputProperties>` to `ThroughputPoller`. ([#4096](https://github.com/Azure/azure-sdk-for-rust/pull/4096))
19
20
- Removed `CreateDatabaseOptions::with_throughput()`. Database-level shared throughput provisioning is no longer supported through the SDK. Use container-level throughput instead. ([#4147](https://github.com/Azure/azure-sdk-for-rust/pull/4147))
0 commit comments