From 33b03e6db14e05f2b4f2f57ebc7df25aa1bd0b9b Mon Sep 17 00:00:00 2001 From: Sean Kane <68240067+seankane-msft@users.noreply.github.com> Date: Wed, 16 Sep 2020 09:53:45 -0700 Subject: [PATCH] removed try/except wrapper on upsert method, added _process_table_error instead of create call (#13815) fixes #13678 --- .../azure/data/tables/_table_client.py | 10 ++-------- .../azure/data/tables/aio/_table_client_async.py | 9 ++------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py index a9646ed546e5..50c73f7be5be 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py @@ -532,7 +532,6 @@ def upsert_entity( # pylint:disable=R1710 partition_key = entity['PartitionKey'] row_key = entity['RowKey'] entity = _add_entity_properties(entity) - try: metadata = None if mode is UpdateMode.MERGE: @@ -556,10 +555,5 @@ def upsert_entity( # pylint:disable=R1710 raise ValueError("""Update mode {} is not supported. For a list of supported modes see the UpdateMode enum""".format(mode)) return _trim_service_metadata(metadata) - except ResourceNotFoundError: - return self.create_entity( - partition_key=partition_key, - row_key=row_key, - table_entity_properties=entity, - **kwargs - ) + except HttpResponseError as error: + _process_table_error(error) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py index 1eda813a4c62..2f4837fb1271 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py @@ -567,10 +567,5 @@ async def upsert_entity( raise ValueError("""Update mode {} is not supported. For a list of supported modes see the UpdateMode enum""".format(mode)) return _trim_service_metadata(metadata) - except ResourceNotFoundError: - return await self.create_entity( - partition_key=partition_key, - row_key=row_key, - table_entity_properties=entity, - **kwargs - ) + except HttpResponseError as error: + _process_table_error(error)