Skip to content

Commit

Permalink
[Cosmos] Defaults partitionKeyValue to '[{}]' when missing in Read/De…
Browse files Browse the repository at this point in the history
…lete bulk operations (#13143)

* Defaults to '[{}]' partition for Read/Delete when partitionKey not present in args

* format

* Update changelog

* Update sdk/cosmosdb/cosmos/CHANGELOG.md

Co-authored-by: Steve Faulkner <[email protected]>

Co-authored-by: Steve Faulkner <[email protected]>
  • Loading branch information
zfoster and southpolesteve authored Jan 12, 2021
1 parent b484888 commit 2972c14
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions sdk/cosmosdb/cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 3.9.5

- BUGFIX: Defaults partitionKeyValue to `'[{}]'` when missing in Read/Delete bulk operations

## 3.9.4 (2021-01-04)

- BUGFIX: Sums group by operations for cross-partition queries correctly with null values
Expand Down
5 changes: 5 additions & 0 deletions sdk/cosmosdb/cosmos/src/utils/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ export function decorateOperation(
) {
const pk = extractPartitionKey(operation.resourceBody, definition);
return { ...operation, partitionKey: JSON.stringify(pk) } as Operation;
} else if (
operation.operationType === BulkOperationType.Read ||
operation.operationType === BulkOperationType.Delete
) {
return { ...operation, partitionKey: "[{}]" };
}
return operation as Operation;
}
1 change: 0 additions & 1 deletion sdk/cosmosdb/cosmos/test/public/functional/item.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ describe("bulk item operations", function() {
it("deletes an item with default partition", async function() {
const operation: OperationInput = {
operationType: BulkOperationType.Delete,
partitionKey: {},
id: deleteItemId
};

Expand Down

0 comments on commit 2972c14

Please sign in to comment.