Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pamelafox opened this issue Feb 1, 2025 · 0 comments
Labels
needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team.

Comments

@pamelafox
Copy link
Member

  • 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.

@github-actions github-actions bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team.
Projects
None yet
Development

No branches or pull requests

1 participant