Skip to content

execute_item_batch can't accept multiple items for upsert and delete operations #39523

Open
@pamelafox

Description

@pamelafox
  • Package Name: azure-cosmos
  • Package Version: 4.9.0
  • Operating System: Mac OS X
  • Python Version: Python 3.12

Describe the bug

I tried using code like this:

batch_operations = [
("upsert", tuple([session_item] + message_pair_items))
]
await container.execute_item_batch(batch_operations=batch_operations, partition_key=[entra_oid, session_id])

That results in an error in the SDK however ("operation" is undefined), arising from this code lacking "upsert"--

        elif len(args) == 2:
            if operation_type.lower() == "replace":
                operation = {"operationType": "Replace",
                             "id": args[0],
                             "resourceBody": args[1]}
            elif operation_type.lower() == "patch":
                operation = {"operationType": "Patch",
                             "id": args[0],
                             "resourceBody": {"operations": args[1]}}
                filter_predicate = kwargs.pop("filter_predicate", None)
                if filter_predicate is not None:
                    operation["resourceBody"]["condition"] = filter_predicate

Mark says that the .NET SDK has equivalent functionality for upsert and delete. And if for some reason they dont work, the error should be better.

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.CosmosService AttentionWorkflow: This issue is responsible by Azure service team.

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions