Skip to content

[Cosmos] bugfix: set automaticIdGeneration to false properly for upsert_item() calls - #24150

Merged
tjprescott merged 83 commits into
Azure:mainfrom
simorenoh:bugfix-disableautomaticidgen
Apr 28, 2022
Merged

[Cosmos] bugfix: set automaticIdGeneration to false properly for upsert_item() calls#24150
tjprescott merged 83 commits into
Azure:mainfrom
simorenoh:bugfix-disableautomaticidgen

Conversation

@simorenoh

@simorenoh simorenoh commented Apr 22, 2022

Copy link
Copy Markdown
Member

Seems like this option wasn't being parsed properly due to wrong naming, which was allowing for the creation of items with auto-generated id's through the use of upsert_item() method. This is wrong behavior.

With these changes the backend successfully throws errors when users upsert items without an 'id' field in the body. The parsing was happening in _cosmos_client_connection.py, _GetContainerIdWithPathForItem method, and was always being ignored since the option was not being properly set in the upsert_item call.

Marked it as a breaking change since this may have allowed users to create items in the past without passing in an 'id' field in their item bodies - which would now no longer be possible.

simorenoh and others added 30 commits August 13, 2021 13:14
* Removed some stuff

* Looking at constructors

* Updated request

* Added client close

* working client creation

Co-authored-by: simorenoh <simonmorenohe@gmail.com>
database read works, but ignored exception is returned:
Fatal error on SSL transport
NoneType has no attribute 'send' (_loop._proactor.send)
RuntimeError: Event loop is closed
Unclosed connector/ connection
Added methods needed to use async with when initializing client, but logs output "Exception ignored... Runtime Error: Event loop is closed"
missing upsert and other resources
missing read_all_items and both query methods for container class
Complete item CRUD functionality - only missing queries
Query functionality and container query methods
also fixed README and added examples_async
@azure-sdk

Copy link
Copy Markdown
Collaborator

API change check for azure-cosmos

API changes are not detected in this pull request for azure-cosmos

@tjprescott tjprescott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm somewhat curious why if the service supports an auto-generated ID the SDK doesn't, but clearly this was not the intended behavior in the SDK.

@simorenoh

Copy link
Copy Markdown
Member Author

/azp run python - cosmos - ci

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@tjprescott
tjprescott merged commit f80d07b into Azure:main Apr 28, 2022
@simorenoh
simorenoh deleted the bugfix-disableautomaticidgen branch May 5, 2022 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants