Skip to content

Commit f80d07b

Browse files
simorenohannatischgahl-levytjprescott
authored
[Cosmos] bugfix: set automaticIdGeneration to false properly for upsert_item() calls (#24150)
* initial commit * Client Constructor (#20310) * Removed some stuff * Looking at constructors * Updated request * Added client close * working client creation Co-authored-by: simorenoh <[email protected]> * read database 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 * Update simon_testfile.py * with coroutine Added methods needed to use async with when initializing client, but logs output "Exception ignored... Runtime Error: Event loop is closed" * Update simon_testfile.py * small changes * async with returns no exceptions * async read container * async item read * cleaning up * create item/ database methods * item delete working * docs replace functionality missing upsert and other resources * upsert functionality missing read_all_items and both query methods for container class * missing query methods * CRUD for udf, sproc, triggers * initial query logic + container methods * missing some execution logic and tests * oops * fully working queries * small fix to query_items() also fixed README and added examples_async * Update _cosmos_client_connection_async.py * Update _cosmos_client_connection.py * documentation update * updated MIT dates and get_user_client() description * Update CHANGELOG.md * Delete simon_testfile.py * leftover retry utility * Update README.md * docs and removed six package * changes based on comments still missing discussion resolution on SSL verification and tests for async functionality under test module (apart from samples which are basically end to end tests) * small change in type hints * updated readme * fixes based on conversations * added missing type comments * update changelog for ci pipeline * added typehints, moved params into keywords, added decorators, made _connection_policy private * changes based on sync with central sdk * remove is_system_key from scripts (only used in execute_sproc) is_system_key verifies that an empty partition key is properly dealt with if ['partitionKey']['systemKey'] exists in the container options - however, we do not allow containers to be created with empty partition key values in the python sdk, so the functionality is needless * Revert "remove is_system_key from scripts (only used in execute_sproc)" Reverting last commit, will find way to init is_system_key for now * async script proxy using composition * pylint * capitalized constants * Apply suggestions from code review Clarifying comments for README Co-authored-by: Gahl Levy <[email protected]> * closing python code snippet * last doc updates * Update sdk/cosmos/azure-cosmos/CHANGELOG.md Co-authored-by: Simon Moreno <[email protected]> * version update * cosmos updates for release * fix connection string comma * Update CHANGELOG.md * fixing extra await keyword in sample * Update CHANGELOG.md * Update CHANGELOG.md * auto id generation was on for upserts without id values * Update CHANGELOG.md Co-authored-by: annatisch <[email protected]> Co-authored-by: Gahl Levy <[email protected]> Co-authored-by: Travis Prescott <[email protected]>
1 parent feb23dc commit f80d07b

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

sdk/cosmos/azure-cosmos/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
### 4.3.0b5 (Unreleased)
44

5+
#### Breaking Changes
6+
- Bugfix: Automatic Id generation for items was turned on for `upsert_items()` method when no 'id' value was present in document body.
7+
Method call will now require an 'id' field to be present in the document body.
8+
59
#### Other Changes
610
- Marked the GetAuthorizationMethod for deprecation since it will no longer be public in a future release.
711
- Added samples showing how to configure retry options for both the sync and async clients.

sdk/cosmos/azure-cosmos/azure/cosmos/aio/container.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ async def upsert_item(
445445
"""
446446
request_options = _build_options(kwargs)
447447
response_hook = kwargs.pop('response_hook', None)
448-
request_options["disableIdGeneration"] = True
448+
request_options["disableAutomaticIdGeneration"] = True
449449
if pre_trigger_include is not None:
450450
request_options["preTriggerInclude"] = pre_trigger_include
451451
if post_trigger_include is not None:
@@ -492,7 +492,7 @@ async def replace_item(
492492
item_link = self._get_document_link(item)
493493
request_options = _build_options(kwargs)
494494
response_hook = kwargs.pop('response_hook', None)
495-
request_options["disableIdGeneration"] = True
495+
request_options["disableAutomaticIdGeneration"] = True
496496
if pre_trigger_include is not None:
497497
request_options["preTriggerInclude"] = pre_trigger_include
498498
if post_trigger_include is not None:

sdk/cosmos/azure-cosmos/azure/cosmos/container.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def replace_item(
426426
item_link = self._get_document_link(item)
427427
request_options = build_options(kwargs)
428428
response_hook = kwargs.pop('response_hook', None)
429-
request_options["disableIdGeneration"] = True
429+
request_options["disableAutomaticIdGeneration"] = True
430430
if populate_query_metrics is not None:
431431
request_options["populateQueryMetrics"] = populate_query_metrics
432432
if pre_trigger_include is not None:
@@ -472,7 +472,7 @@ def upsert_item(
472472
"""
473473
request_options = build_options(kwargs)
474474
response_hook = kwargs.pop('response_hook', None)
475-
request_options["disableIdGeneration"] = True
475+
request_options["disableAutomaticIdGeneration"] = True
476476
if populate_query_metrics is not None:
477477
request_options["populateQueryMetrics"] = populate_query_metrics
478478
if pre_trigger_include is not None:

0 commit comments

Comments
 (0)