From e6f9bacf5751cce1eac9a7fb6096676966004449 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 16 Sep 2020 08:57:42 -0700 Subject: [PATCH 1/2] removed try/except wrapper on upsert method, added _process_table_error instead of create call --- .../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 9c25f78b5905..63c787d41561 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) \ No newline at end of file From 7413c82248228ae7b72b31a86c354675ecc34faf Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 16 Sep 2020 09:33:44 -0700 Subject: [PATCH 2/2] forgot a newline --- .../azure/data/tables/aio/_table_client_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 63c787d41561..95efdab2e6fd 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 @@ -568,4 +568,4 @@ async def upsert_entity( For a list of supported modes see the UpdateMode enum""".format(mode)) return _trim_service_metadata(metadata) except HttpResponseError as error: - _process_table_error(error) \ No newline at end of file + _process_table_error(error)