From b4fc2b7b03346c9cf1deb4eb2443d67652833095 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 20 Apr 2021 16:01:21 -0400 Subject: [PATCH 1/8] changing entity property type->edm_type, both args required --- .../azure/data/tables/_deserialize.py | 10 ++- .../azure/data/tables/_entity.py | 77 +++++++++---------- .../azure/data/tables/_serialize.py | 2 +- .../tests/test_table_batch.py | 76 ++++++------------ .../tests/test_table_batch_async.py | 38 ++++----- .../tests/test_table_batch_cosmos.py | 28 +++---- .../tests/test_table_batch_cosmos_async.py | 34 ++++---- .../tests/test_table_entity.py | 4 +- .../tests/test_table_entity_async.py | 4 +- .../tests/test_table_entity_cosmos.py | 4 +- .../tests/test_table_entity_cosmos_async.py | 4 +- 11 files changed, 126 insertions(+), 155 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_deserialize.py b/sdk/tables/azure-data-tables/azure/data/tables/_deserialize.py index d5eba3ed521b..0e02f1ce7490 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_deserialize.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_deserialize.py @@ -78,14 +78,17 @@ def _deserialize_table_creation(response, _, headers): def _from_entity_binary(value): - return EntityProperty(_decode_base64_to_bytes(value)) + # type: (str) -> EntityProperty + return EntityProperty(_decode_base64_to_bytes(value), EdmType.BINARY) def _from_entity_int32(value): - return EntityProperty(int(value)) + # type: (str) -> EntityProperty + return EntityProperty(int(value), EdmType.INT32) def _from_entity_int64(value): + # type: (str) -> EntityProperty return EntityProperty(int(value), EdmType.INT64) @@ -125,7 +128,8 @@ def _from_entity_guid(value): def _from_entity_str(value): - return EntityProperty(value=value, type=EdmType.STRING) + # type: (str) -> EntityProperty + return EntityProperty(value, EdmType.STRING) _EDM_TYPES = [ diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py index 8d20acf5fefc..f9218b4914b0 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py @@ -4,9 +4,10 @@ # license information. # -------------------------------------------------------------------------- from enum import Enum -from datetime import datetime -from uuid import UUID -import six +from typing import Any, Dict +# from datetime import datetime +# import six +# from uuid import UUID from ._error import _ERROR_ATTRIBUTE_MISSING, _ERROR_VALUE_TOO_LARGE @@ -80,11 +81,8 @@ class EntityProperty(object): entity.x = EntityProperty('y', EdmType.STRING) """ - def __init__( - self, - value=None, # type: Any - type=None, # type: Union[str,EdmType] pylint: disable=redefined-builtin - ): + def __init__(self, value, edm_type): + # type: (Any, EdmType) -> None """ Represents an Azure Table. Returned by list_tables. @@ -93,38 +91,37 @@ def __init__( :param Any value: The value of the property. """ self.value = value - if type is not None: - self.type = type - elif isinstance(value, six.text_type): - try: - self.value = UUID(value) - self.type = EdmType.GUID - except ValueError: - self.type = EdmType.STRING - elif isinstance(value, six.binary_type): - self.type = EdmType.BINARY - elif isinstance(value, bool): - self.type = EdmType.BOOLEAN - elif isinstance(value, six.integer_types): - if value.bit_length() <= 32: - self.type = EdmType.INT32 - else: - raise TypeError( - _ERROR_VALUE_TOO_LARGE.format(str(value), EdmType.INT32) - ) - elif isinstance(value, datetime): - self.type = EdmType.DATETIME - elif isinstance(value, float): - self.type = EdmType.DOUBLE - else: - raise ValueError( - """Type of {} could not be inferred. Acceptable types are bytes, int, uuid.UUID, - datetime, string, int32, int64, float, and boolean. Refer to - azure.data.tables.EdmType for more information. - """.format( - value - ) - ) + self.edm_type = edm_type + # elif isinstance(value, six.text_type): + # try: + # self.value = UUID(value) + # self.type = EdmType.GUID + # except ValueError: + # self.type = EdmType.STRING + # elif isinstance(value, six.binary_type): + # self.type = EdmType.BINARY + # elif isinstance(value, bool): + # self.type = EdmType.BOOLEAN + # elif isinstance(value, six.integer_types): + # if value.bit_length() <= 32: + # self.type = EdmType.INT32 + # else: + # raise TypeError( + # _ERROR_VALUE_TOO_LARGE.format(str(value), EdmType.INT32) + # ) + # elif isinstance(value, datetime): + # self.type = EdmType.DATETIME + # elif isinstance(value, float): + # self.type = EdmType.DOUBLE + # else: + # raise ValueError( + # """Type of {} could not be inferred. Acceptable types are bytes, int, uuid.UUID, + # datetime, string, int32, int64, float, and boolean. Refer to + # azure.data.tables.EdmType for more information. + # """.format( + # value + # ) + # ) class EdmType(str, Enum): diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py b/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py index 58a51eb291ca..9bbb92714067 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py @@ -216,7 +216,7 @@ def _add_entity_properties(source): elif isinstance(value, datetime): mtype, value = _to_entity_datetime(value) elif isinstance(value, EntityProperty): - conv = _EDM_TO_ENTITY_CONVERSIONS.get(value.type) + conv = _EDM_TO_ENTITY_CONVERSIONS.get(value.edm_type) if conv is None: raise TypeError(_ERROR_TYPE_NOT_SUPPORTED.format(value.type)) mtype, value = conv(value.value) diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch.py b/sdk/tables/azure-data-tables/tests/test_table_batch.py index 204135f319d2..d99a70b234d7 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch.py @@ -109,7 +109,7 @@ def _create_random_entity_dict(self, pk=None, rk=None): 'Birthday': datetime(1973, 10, 4, tzinfo=tzutc()), 'birthday': datetime(1970, 10, 4, tzinfo=tzutc()), 'binary': b'binary', - 'other': EntityProperty(value=20, type=EdmType.INT32), + 'other': EntityProperty(20, EdmType.INT32), 'clsid': uuid.UUID('c9da6455-213d-42c9-9a79-3e9149a57833') } return TableEntity(**properties) @@ -182,10 +182,10 @@ def test_batch_single_insert(self, tables_storage_account_name, tables_primary_s entity = TableEntity() entity.PartitionKey = '001' entity.RowKey = 'batch_insert' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -219,10 +219,10 @@ def test_batch_single_update(self, tables_storage_account_name, tables_primary_s entity = TableEntity() entity.PartitionKey = '001' entity.RowKey = 'batch_insert' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() resp = self.table.create_entity(entity) @@ -256,10 +256,10 @@ def test_batch_update(self, tables_storage_account_name, tables_primary_storage_ entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_update' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() self.table.create_entity(entity) @@ -294,10 +294,10 @@ def test_batch_merge(self, tables_storage_account_name, tables_primary_storage_a entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_merge' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() self.table.create_entity(entity) @@ -395,10 +395,10 @@ def test_batch_single_op_if_doesnt_match(self, tables_storage_account_name, tabl # Act entity = TableEntity() entity.PartitionKey = 'batch_inserts' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) batch = self.table.create_batch() transaction_count = 0 @@ -442,7 +442,7 @@ def test_batch_insert_replace(self, tables_storage_account_name, tables_primary_ entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -474,7 +474,7 @@ def test_batch_insert_merge(self, tables_storage_account_name, tables_primary_st entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -503,10 +503,10 @@ def test_batch_delete(self, tables_storage_account_name, tables_primary_storage_ entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_delete' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() self.table.create_entity(entity) @@ -536,10 +536,10 @@ def test_batch_inserts(self, tables_storage_account_name, tables_primary_storage # Act entity = TableEntity() entity.PartitionKey = 'batch_inserts' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) batch = self.table.create_batch() transaction_count = 0 @@ -574,10 +574,10 @@ def test_batch_all_operations_together(self, tables_storage_account_name, tables entity = TableEntity() entity.PartitionKey = '003' entity.RowKey = 'batch_all_operations_together-1' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() self.table.create_entity(entity) entity.RowKey = 'batch_all_operations_together-2' @@ -652,10 +652,10 @@ def test_batch_reuse(self, tables_storage_account_name, tables_primary_storage_a entity = TableEntity() entity.PartitionKey = '003' entity.RowKey = 'batch_all_operations_together-1' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -847,10 +847,10 @@ def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_storag entity = TableEntity() entity.PartitionKey = 'batch_inserts' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) batch = table.create_batch() transaction_count = 0 @@ -869,33 +869,3 @@ def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_storag assert total_entities == transaction_count finally: self._tear_down() - - - -class TestTableUnitTest(TableTestCase): - - #--Test cases for batch --------------------------------------------- - def test_inferred_types(self): - # Arrange - # Act - entity = TableEntity() - entity.PartitionKey = '003' - entity.RowKey = 'batch_all_operations_together-1' - entity.test = EntityProperty(True) - entity.test2 = EntityProperty(b'abcdef') - entity.test3 = EntityProperty(u'c9da6455-213d-42c9-9a79-3e9149a57833') - entity.test4 = EntityProperty(datetime(1973, 10, 4, tzinfo=tzutc())) - entity.test5 = EntityProperty(u"stringystring") - entity.test6 = EntityProperty(3.14159) - entity.test7 = EntityProperty(100) - entity.test8 = EntityProperty(2 ** 33, EdmType.INT64) - - # Assert - assert entity.test.type == EdmType.BOOLEAN - assert entity.test2.type == EdmType.BINARY - assert entity.test3.type == EdmType.GUID - assert entity.test4.type == EdmType.DATETIME - assert entity.test5.type == EdmType.STRING - assert entity.test6.type == EdmType.DOUBLE - assert entity.test7.type == EdmType.INT32 - assert entity.test8.type == EdmType.INT64 \ No newline at end of file diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_async.py b/sdk/tables/azure-data-tables/tests/test_table_batch_async.py index aad24c21c8a9..0a300bcdb05d 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_async.py @@ -107,7 +107,7 @@ def _create_random_entity_dict(self, pk=None, rk=None): 'Birthday': datetime(1973, 10, 4, tzinfo=tzutc()), 'birthday': datetime(1970, 10, 4, tzinfo=tzutc()), 'binary': b'binary', - 'other': EntityProperty(value=20, type=EdmType.INT32), + 'other': EntityProperty(20, EdmType.INT32), 'clsid': uuid.UUID('c9da6455-213d-42c9-9a79-3e9149a57833') } return TableEntity(**properties) @@ -179,10 +179,10 @@ async def test_batch_single_insert(self, tables_storage_account_name, tables_pri entity = TableEntity() entity.PartitionKey = '001' entity.RowKey = 'batch_insert' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -214,10 +214,10 @@ async def test_batch_single_update(self, tables_storage_account_name, tables_pri entity = TableEntity() entity.PartitionKey = '001' entity.RowKey = 'batch_insert' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() resp = await self.table.create_entity(entity) @@ -251,10 +251,10 @@ async def test_batch_update(self, tables_storage_account_name, tables_primary_st entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_update' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() await self.table.create_entity(entity) @@ -287,10 +287,10 @@ async def test_batch_merge(self, tables_storage_account_name, tables_primary_sto entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_merge' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() await self.table.create_entity(entity) @@ -388,7 +388,7 @@ async def test_batch_insert_replace(self, tables_storage_account_name, tables_pr entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -419,7 +419,7 @@ async def test_batch_insert_merge(self, tables_storage_account_name, tables_prim entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -447,10 +447,10 @@ async def test_batch_delete(self, tables_storage_account_name, tables_primary_st entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_delete' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() await self.table.create_entity(entity) @@ -479,10 +479,10 @@ async def test_batch_inserts(self, tables_storage_account_name, tables_primary_s # Act entity = TableEntity() entity.PartitionKey = 'batch_inserts' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) transaction_count = 0 batch = self.table.create_batch() @@ -519,10 +519,10 @@ async def test_batch_all_operations_together(self, tables_storage_account_name, entity = TableEntity() entity.PartitionKey = '003' entity.RowKey = 'batch_all_operations_together-1' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() await self.table.create_entity(entity) entity.RowKey = 'batch_all_operations_together-2' @@ -739,10 +739,10 @@ async def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_ entity = TableEntity() entity.PartitionKey = 'batch_inserts' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) batch = table.create_batch() transaction_count = 0 diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos.py index 9fbb5cb5d3a6..04e8db184a71 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos.py @@ -104,7 +104,7 @@ def _create_random_entity_dict(self, pk=None, rk=None): 'Birthday': datetime(1973, 10, 4, tzinfo=tzutc()), 'birthday': datetime(1970, 10, 4, tzinfo=tzutc()), 'binary': b'binary', - 'other': EntityProperty(value=20, type=EdmType.INT32), + 'other': EntityProperty(20, EdmType.INT32), 'clsid': uuid.UUID('c9da6455-213d-42c9-9a79-3e9149a57833') } return TableEntity(**properties) @@ -181,7 +181,7 @@ def test_batch_insert(self, tables_cosmos_account_name, tables_primary_cosmos_ac entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -210,10 +210,10 @@ def test_batch_update(self, tables_cosmos_account_name, tables_primary_cosmos_ac entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_update' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() self.table.create_entity(entity) @@ -247,10 +247,10 @@ def test_batch_merge(self, tables_cosmos_account_name, tables_primary_cosmos_acc entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_merge' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() self.table.create_entity(entity) @@ -350,7 +350,7 @@ def test_batch_insert_replace(self, tables_cosmos_account_name, tables_primary_c entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -382,7 +382,7 @@ def test_batch_insert_merge(self, tables_cosmos_account_name, tables_primary_cos entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -411,10 +411,10 @@ def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cosmos_ac entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_delete' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() self.table.create_entity(entity) @@ -444,10 +444,10 @@ def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_cosmos_a # Act entity = TableEntity() entity.PartitionKey = 'batch_inserts' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) batch = self.table.create_batch() transaction_count = 0 @@ -482,10 +482,10 @@ def test_batch_all_operations_together(self, tables_cosmos_account_name, tables_ entity = TableEntity() entity.PartitionKey = '003' entity.RowKey = 'batch_all_operations_together-1' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() self.table.create_entity(entity) entity.RowKey = 'batch_all_operations_together-2' diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py index 39dfd38a3a42..920999661abb 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py @@ -107,7 +107,7 @@ def _create_random_entity_dict(self, pk=None, rk=None): 'Birthday': datetime(1973, 10, 4, tzinfo=tzutc()), 'birthday': datetime(1970, 10, 4, tzinfo=tzutc()), 'binary': b'binary', - 'other': EntityProperty(value=20, type=EdmType.INT32), + 'other': EntityProperty(20, EdmType.INT32), 'clsid': uuid.UUID('c9da6455-213d-42c9-9a79-3e9149a57833') } return TableEntity(**properties) @@ -179,10 +179,10 @@ async def test_batch_single_insert(self, tables_cosmos_account_name, tables_prim entity = TableEntity() entity.PartitionKey = '001' entity.RowKey = 'batch_insert' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -214,10 +214,10 @@ async def test_batch_single_update(self, tables_cosmos_account_name, tables_prim entity = TableEntity() entity.PartitionKey = '001' entity.RowKey = 'batch_insert' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() resp = await self.table.create_entity(entity) @@ -251,10 +251,10 @@ async def test_batch_update(self, tables_cosmos_account_name, tables_primary_cos entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_update' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() await self.table.create_entity(entity) @@ -287,10 +287,10 @@ async def test_batch_merge(self, tables_cosmos_account_name, tables_primary_cosm entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_merge' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() await self.table.create_entity(entity) @@ -388,7 +388,7 @@ async def test_batch_insert_replace(self, tables_cosmos_account_name, tables_pri entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -419,7 +419,7 @@ async def test_batch_insert_merge(self, tables_cosmos_account_name, tables_prima entity.test = True entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() batch = self.table.create_batch() @@ -447,10 +447,10 @@ async def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cos entity = TableEntity() entity.PartitionKey = u'001' entity.RowKey = u'batch_delete' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = u'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() await self.table.create_entity(entity) @@ -479,10 +479,10 @@ async def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_co # Act entity = TableEntity() entity.PartitionKey = 'batch_inserts' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) transaction_count = 0 batch = self.table.create_batch() @@ -519,10 +519,10 @@ async def test_batch_all_operations_together(self, tables_cosmos_account_name, t entity = TableEntity() entity.PartitionKey = '003' entity.RowKey = 'batch_all_operations_together-1' - entity.test = EntityProperty(True) + entity.test = EntityProperty(True, EdmType.BOOLEAN) entity.test2 = 'value' entity.test3 = 3 - entity.test4 = EntityProperty(1234567890) + entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() await self.table.create_entity(entity) entity.RowKey = 'batch_all_operations_together-2' diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity.py b/sdk/tables/azure-data-tables/tests/test_table_entity.py index c3fe21db1a90..36e69928c92e 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity.py @@ -132,7 +132,7 @@ def _insert_two_opposite_entities(self, pk=None, rk=None): 'Birthday': datetime(1993, 4, 1, tzinfo=tzutc()), 'birthday': datetime(1990, 4, 1, tzinfo=tzutc()), 'binary': b'binary-binary', - 'other': EntityProperty(value=40, type=EdmType.INT32), + 'other': EntityProperty(40, EdmType.INT32), 'clsid': uuid.UUID('c8da6455-213e-42d9-9b79-3f9149a57833') } entity = TableEntity(**properties) @@ -159,7 +159,7 @@ def _create_random_entity_dict(self, pk=None, rk=None): 'Birthday': datetime(1973, 10, 4, tzinfo=tzutc()), 'birthday': datetime(1970, 10, 4, tzinfo=tzutc()), 'binary': b'binary', - 'other': EntityProperty(value=20, type=EdmType.INT32), + 'other': EntityProperty(20, EdmType.INT32), 'clsid': uuid.UUID('c9da6455-213d-42c9-9a79-3e9149a57833') } return TableEntity(**properties) diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py index c06b901571db..274a56e1d05c 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py @@ -126,7 +126,7 @@ async def _insert_two_opposite_entities(self, pk=None, rk=None): 'Birthday': datetime(1993, 4, 1, tzinfo=tzutc()), 'birthday': datetime(1990, 4, 1, tzinfo=tzutc()), 'binary': b'binary-binary', - 'other': EntityProperty(value=40, type=EdmType.INT32), + 'other': EntityProperty(40, EdmType.INT32), 'clsid': uuid.UUID('c8da6455-213e-42d9-9b79-3f9149a57833') } entity = TableEntity(**properties) @@ -154,7 +154,7 @@ def _create_random_entity_dict(self, pk=None, rk=None): 'Birthday': datetime(1973, 10, 4, tzinfo=tzutc()), 'birthday': datetime(1970, 10, 4, tzinfo=tzutc()), 'binary': b'binary', - 'other': EntityProperty(value=20, type=EdmType.INT32), + 'other': EntityProperty(20, EdmType.INT32), 'clsid': uuid.UUID('c9da6455-213d-42c9-9a79-3e9149a57833') } return TableEntity(**properties) diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py index 17d122c927e5..ae2bdb90b99d 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py @@ -135,7 +135,7 @@ def _insert_two_opposite_entities(self, pk=None, rk=None): 'Birthday': datetime(1993, 4, 1, tzinfo=tzutc()), 'birthday': datetime(1990, 4, 1, tzinfo=tzutc()), 'binary': b'binary-binary', - 'other': EntityProperty(value=40, type=EdmType.INT32), + 'other': EntityProperty(40, EdmType.INT32), 'clsid': uuid.UUID('c8da6455-213e-42d9-9b79-3f9149a57833') } entity = TableEntity(**properties) @@ -162,7 +162,7 @@ def _create_random_entity_dict(self, pk=None, rk=None): 'Birthday': datetime(1973, 10, 4, tzinfo=tzutc()), 'birthday': datetime(1970, 10, 4, tzinfo=tzutc()), 'binary': b'binary', - 'other': EntityProperty(value=20, type=EdmType.INT32), + 'other': EntityProperty(20, EdmType.INT32), 'clsid': uuid.UUID('c9da6455-213d-42c9-9a79-3e9149a57833') } return TableEntity(**properties) diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py index e25be42641d0..b4978ec8022d 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py @@ -128,7 +128,7 @@ async def _insert_two_opposite_entities(self, pk=None, rk=None): 'Birthday': datetime(1993, 4, 1, tzinfo=tzutc()), 'birthday': datetime(1990, 4, 1, tzinfo=tzutc()), 'binary': b'binary-binary', - 'other': EntityProperty(value=40, type=EdmType.INT32), + 'other': EntityProperty(40, EdmType.INT32), 'clsid': uuid.UUID('c8da6455-213e-42d9-9b79-3f9149a57833') } entity = TableEntity(**properties) @@ -156,7 +156,7 @@ def _create_random_entity_dict(self, pk=None, rk=None): 'Birthday': datetime(1973, 10, 4, tzinfo=tzutc()), 'birthday': datetime(1970, 10, 4, tzinfo=tzutc()), 'binary': b'binary', - 'other': EntityProperty(value=20, type=EdmType.INT32), + 'other': EntityProperty(20, EdmType.INT32), 'clsid': uuid.UUID('c9da6455-213d-42c9-9a79-3e9149a57833') } return TableEntity(**properties) From 0a3d6d0e328dff8a86f7ee70169c409fe8e46af5 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 20 Apr 2021 16:03:30 -0400 Subject: [PATCH 2/8] removing commented out code --- .../azure/data/tables/_entity.py | 34 ++----------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py index f9218b4914b0..9e0244799c25 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py @@ -84,44 +84,14 @@ class EntityProperty(object): def __init__(self, value, edm_type): # type: (Any, EdmType) -> None """ - Represents an Azure Table. Returned by list_tables. + Represents an Azure Table. Returned by list_tables and query_tables. :param type: The type of the property. - :type type: str or EdmType + :type type: EdmType :param Any value: The value of the property. """ self.value = value self.edm_type = edm_type - # elif isinstance(value, six.text_type): - # try: - # self.value = UUID(value) - # self.type = EdmType.GUID - # except ValueError: - # self.type = EdmType.STRING - # elif isinstance(value, six.binary_type): - # self.type = EdmType.BINARY - # elif isinstance(value, bool): - # self.type = EdmType.BOOLEAN - # elif isinstance(value, six.integer_types): - # if value.bit_length() <= 32: - # self.type = EdmType.INT32 - # else: - # raise TypeError( - # _ERROR_VALUE_TOO_LARGE.format(str(value), EdmType.INT32) - # ) - # elif isinstance(value, datetime): - # self.type = EdmType.DATETIME - # elif isinstance(value, float): - # self.type = EdmType.DOUBLE - # else: - # raise ValueError( - # """Type of {} could not be inferred. Acceptable types are bytes, int, uuid.UUID, - # datetime, string, int32, int64, float, and boolean. Refer to - # azure.data.tables.EdmType for more information. - # """.format( - # value - # ) - # ) class EdmType(str, Enum): From 86a7fcbd247384d1e9e6f9d9705fc0ab4d8ea9ae Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 20 Apr 2021 17:56:59 -0400 Subject: [PATCH 3/8] lint fixes --- sdk/tables/azure-data-tables/azure/data/tables/_entity.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py index 9e0244799c25..63c285ee2bea 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py @@ -5,11 +5,8 @@ # -------------------------------------------------------------------------- from enum import Enum from typing import Any, Dict -# from datetime import datetime -# import six -# from uuid import UUID -from ._error import _ERROR_ATTRIBUTE_MISSING, _ERROR_VALUE_TOO_LARGE +from ._error import _ERROR_ATTRIBUTE_MISSING class TableEntity(dict): From 877c6121535d87e1d02e560192fcbe6b2fce38e0 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 20 Apr 2021 19:30:55 -0400 Subject: [PATCH 4/8] updated changelog BEFORE anna requests it --- sdk/tables/azure-data-tables/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index eaa624d292d4..b5c9bb5878a1 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -8,6 +8,8 @@ * The `TableItem.table_name` has been renamed to `TableItem.name`. * Removed `BatchTransactionResult` object in favor of returning an iterable of batched entities with returned metadata. * Removed Batching context-manager behavior +* Changed optional `value` and `type` arguments of `EntityProperty` to required. +* Renamed `EntityProperty.type` to `EntityProperty.edm_type`. **Fixes** * Fixed issue with Cosmos merge operations. From ece28c4568d5a061a4a36e4e67410dd6a86f17c1 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Thu, 29 Apr 2021 14:48:22 -0400 Subject: [PATCH 5/8] turning edmtype into a named tuple --- .../azure/data/tables/_entity.py | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py index 63c285ee2bea..948feb31e01a 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- from enum import Enum -from typing import Any, Dict +from typing import Any, Dict, Union, NamedTuple from ._error import _ERROR_ATTRIBUTE_MISSING @@ -66,31 +66,6 @@ def __dir__(self): return dir({}) + list(self.keys()) -class EntityProperty(object): - """ - An entity property. Used to explicitly set :class:`~EdmType` when necessary. - - Values which require explicit typing are GUID, INT64, and BINARY. Other EdmTypes - may be explicitly create as EntityProperty objects but need not be. For example, - the below with both create STRING typed properties on the entity:: - entity = TableEntity() - entity.a = 'b' - entity.x = EntityProperty('y', EdmType.STRING) - """ - - def __init__(self, value, edm_type): - # type: (Any, EdmType) -> None - """ - Represents an Azure Table. Returned by list_tables and query_tables. - - :param type: The type of the property. - :type type: EdmType - :param Any value: The value of the property. - """ - self.value = value - self.edm_type = edm_type - - class EdmType(str, Enum): """ Used by :class:`~.EntityProperty` to represent the type of the entity property @@ -120,3 +95,21 @@ class EdmType(str, Enum): BOOLEAN = "Edm.Boolean" """ Represents a boolean. This type will be inferred for Python bools. """ + + +EntityProperty = NamedTuple("EntityProperty", [("value", Any), ("edm_type", Union[str, EdmType])]) +""" +An entity property. Used to explicitly set :class:`~EdmType` when necessary. + +Values which require explicit typing are GUID, INT64, and BINARY. Other EdmTypes +may be explicitly create as EntityProperty objects but need not be. For example, +the below with both create STRING typed properties on the entity:: + entity = TableEntity() + entity.a = 'b' + entity.x = EntityProperty('y', EdmType.STRING) + +:param value: +:type value: Any +:param edm_type: Type of the value +:type edm_type: str or :class:`~azure.data.tables.EdmType` +""" From 2993b3e9059a9eac66c2795a0f20efaf095726e6 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 30 Apr 2021 13:29:00 -0400 Subject: [PATCH 6/8] updated changelog, update serialize for tuples --- sdk/tables/azure-data-tables/CHANGELOG.md | 1 + .../azure/data/tables/_serialize.py | 16 ++- .../test_table_batch.test_batch_update.yaml | 105 +++++++++--------- ...tch.test_batch_update_if_doesnt_match.yaml | 78 ++++++------- ...able_batch.test_batch_update_if_match.yaml | 82 +++++++------- .../tests/test_table_batch.py | 1 + 6 files changed, 146 insertions(+), 137 deletions(-) diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index e4c090715af0..08861fed7866 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -13,6 +13,7 @@ * Changed optional `value` and `type` arguments of `EntityProperty` to required. * Renamed `EntityProperty.type` to `EntityProperty.edm_type`. * `BatchErrorException` has been renamed to `TableTransactionError`. +* `EntityProperty` is now a tuple. **Fixes** * Fixed issue with Cosmos merge operations. diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py b/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py index 5a052c4ad37d..3c02dd354226 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py @@ -185,6 +185,14 @@ def _to_entity_none(value): # pylint: disable=unused-argument EdmType.INT32: _to_entity_int32, EdmType.INT64: _to_entity_int64, EdmType.STRING: _to_entity_str, + "EdmType.BINARY": _to_entity_binary, + "EdmType.BOOLEAN": _to_entity_bool, + "EdmType.DATETIME": _to_entity_datetime, + "EdmType.DOUBLE": _to_entity_float, + "EdmType.GUID": _to_entity_guid, + "EdmType.INT32": _to_entity_int32, + "EdmType.INT64": _to_entity_int64, + "EdmType.STRING": _to_entity_str, } @@ -225,11 +233,9 @@ def _add_entity_properties(source): mtype, value = conv(value) elif isinstance(value, datetime): mtype, value = _to_entity_datetime(value) - elif isinstance(value, EntityProperty): - conv = _EDM_TO_ENTITY_CONVERSIONS.get(value.edm_type) - if conv is None: - raise TypeError(_ERROR_TYPE_NOT_SUPPORTED.format(value.type)) - mtype, value = conv(value.value) + elif isinstance(value, tuple): + conv = _EDM_TO_ENTITY_CONVERSIONS.get(value[1]) + mtype, value = conv(value[0]) else: conv = _PYTHON_TO_ENTITY_CONVERSIONS.get(type(value)) if conv is None and value is not None: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update.yaml index a8448b7ea956..29353b83ce08 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update.yaml @@ -15,11 +15,11 @@ interactions: DataServiceVersion: - '3.0' Date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT User-Agent: - - azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT x-ms-version: - '2019-02-02' method: POST @@ -33,7 +33,7 @@ interactions: content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT location: - https://fake_table_account.table.core.windows.net/Tables('uttablef0c10dba') server: @@ -51,7 +51,8 @@ interactions: body: '{"PartitionKey": "001", "PartitionKey@odata.type": "Edm.String", "RowKey": "batch_update", "RowKey@odata.type": "Edm.String", "test": true, "test2": "value", "test2@odata.type": "Edm.String", "test3": 3, "test4": 1234567890, "test5": - "2020-12-18T15:42:26Z", "test5@odata.type": "Edm.DateTime"}' + "2021-04-30T21:28:16.696944Z", "test5@odata.type": "Edm.DateTime", "test6": + "1099511627776", "test6@odata.type": "Edm.Int64"}' headers: Accept: - application/json;odata=minimalmetadata @@ -60,33 +61,33 @@ interactions: Connection: - keep-alive Content-Length: - - '293' + - '359' Content-Type: - application/json;odata=nometadata DataServiceVersion: - '3.0' Date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT User-Agent: - - azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT x-ms-version: - '2019-02-02' method: POST uri: https://fake_table_account.table.core.windows.net/uttablef0c10dba response: body: - string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttablef0c10dba/@Element","odata.etag":"W/\"datetime''2020-12-18T15%3A42%3A27.0999424Z''\"","PartitionKey":"001","RowKey":"batch_update","Timestamp":"2020-12-18T15:42:27.0999424Z","test":true,"test2":"value","test3":3,"test4":1234567890,"test5@odata.type":"Edm.DateTime","test5":"2020-12-18T15:42:26Z"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttablef0c10dba/@Element","odata.etag":"W/\"datetime''2021-04-30T17%3A28%3A16.9365254Z''\"","PartitionKey":"001","RowKey":"batch_update","Timestamp":"2021-04-30T17:28:16.9365254Z","test":true,"test2":"value","test3":3,"test4":1234567890,"test5@odata.type":"Edm.DateTime","test5":"2021-04-30T21:28:16.696944Z","test6@odata.type":"Edm.Int64","test6":"1099511627776"}' headers: cache-control: - no-cache content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT etag: - - W/"datetime'2020-12-18T15%3A42%3A27.0999424Z'" + - W/"datetime'2021-04-30T17%3A28%3A16.9365254Z'" location: - https://fake_table_account.table.core.windows.net/uttablef0c10dba(PartitionKey='001',RowKey='batch_update') server: @@ -112,27 +113,27 @@ interactions: DataServiceVersion: - '3.0' Date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT User-Agent: - - azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT x-ms-version: - '2019-02-02' method: GET uri: https://fake_table_account.table.core.windows.net/uttablef0c10dba(PartitionKey='001',RowKey='batch_update') response: body: - string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttablef0c10dba/@Element","odata.etag":"W/\"datetime''2020-12-18T15%3A42%3A27.0999424Z''\"","PartitionKey":"001","RowKey":"batch_update","Timestamp":"2020-12-18T15:42:27.0999424Z","test":true,"test2":"value","test3":3,"test4":1234567890,"test5@odata.type":"Edm.DateTime","test5":"2020-12-18T15:42:26Z"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttablef0c10dba/@Element","odata.etag":"W/\"datetime''2021-04-30T17%3A28%3A16.9365254Z''\"","PartitionKey":"001","RowKey":"batch_update","Timestamp":"2021-04-30T17:28:16.9365254Z","test":true,"test2":"value","test3":3,"test4":1234567890,"test5@odata.type":"Edm.DateTime","test5":"2021-04-30T21:28:16.696944Z","test6@odata.type":"Edm.Int64","test6":"1099511627776"}' headers: cache-control: - no-cache content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:16 GMT etag: - - W/"datetime'2020-12-18T15%3A42%3A27.0999424Z'" + - W/"datetime'2021-04-30T17%3A28%3A16.9365254Z'" server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -145,62 +146,62 @@ interactions: code: 200 message: OK - request: - body: "--batch_5ff21d97-bab1-4302-b72c-41cd68b3e89f\r\nContent-Type: multipart/mixed;\ - \ boundary=changeset_65a17c41-71f5-416e-92bc-150ba9bb6028\r\n\r\n--changeset_65a17c41-71f5-416e-92bc-150ba9bb6028\r\ + body: "--batch_981935d0-a58c-4610-b83f-e6e297f02a5c\r\nContent-Type: multipart/mixed;\ + \ boundary=changeset_5f1b1f85-8533-45f0-bf28-94d5f3202af6\r\n\r\n--changeset_5f1b1f85-8533-45f0-bf28-94d5f3202af6\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ \ 0\r\n\r\nPATCH https://seankaneprim.table.core.windows.net/uttablef0c10dba(PartitionKey='001',RowKey='batch_update')\ \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nIf-Match:\ \ *\r\nContent-Type: application/json\r\nAccept: application/json\r\nContent-Length:\ - \ 294\r\nx-ms-date: Fri, 18 Dec 2020 15:42:26 GMT\r\nDate: Fri, 18 Dec 2020\ - \ 15:42:26 GMT\r\nx-ms-client-request-id: a14bb84c-4147-11eb-8862-58961df361d1\r\ - \n\r\n{\"PartitionKey\": \"001\", \"PartitionKey@odata.type\": \"Edm.String\"\ - , \"RowKey\": \"batch_update\", \"RowKey@odata.type\": \"Edm.String\", \"test\"\ - : true, \"test2\": \"value1\", \"test2@odata.type\": \"Edm.String\", \"test3\"\ - : 3, \"test4\": 1234567890, \"test5\": \"2020-12-18T15:42:26Z\", \"test5@odata.type\"\ - : \"Edm.DateTime\"}\r\n--changeset_65a17c41-71f5-416e-92bc-150ba9bb6028--\r\n\ - \r\n--batch_5ff21d97-bab1-4302-b72c-41cd68b3e89f--\r\n" + \ 360\r\nx-ms-date: Fri, 30 Apr 2021 17:28:17 GMT\r\nDate: Fri, 30 Apr 2021\ + \ 17:28:17 GMT\r\n\r\n{\"PartitionKey\": \"001\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"RowKey\": \"batch_update\", \"RowKey@odata.type\": \"Edm.String\"\ + , \"test\": true, \"test2\": \"value1\", \"test2@odata.type\": \"Edm.String\"\ + , \"test3\": 3, \"test4\": 1234567890, \"test5\": \"2021-04-30T21:28:16.696944Z\"\ + , \"test5@odata.type\": \"Edm.DateTime\", \"test6\": \"1099511627776\", \"test6@odata.type\"\ + : \"Edm.Int64\"}\r\n--changeset_5f1b1f85-8533-45f0-bf28-94d5f3202af6--\r\n\r\ + \n--batch_981935d0-a58c-4610-b83f-e6e297f02a5c--\r\n" headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive Content-Length: - - '1072' + - '1076' Content-Type: - - multipart/mixed; boundary=batch_5ff21d97-bab1-4302-b72c-41cd68b3e89f + - multipart/mixed; boundary=batch_981935d0-a58c-4610-b83f-e6e297f02a5c DataServiceVersion: - '3.0' Date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:17 GMT MaxDataServiceVersion: - 3.0;NetFx User-Agent: - - azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 18 Dec 2020 15:42:26 GMT + - Fri, 30 Apr 2021 17:28:17 GMT x-ms-version: - '2019-02-02' method: POST uri: https://fake_table_account.table.core.windows.net/$batch response: body: - string: "--batchresponse_c4ec0069-d51f-4153-9ed4-a3a6636741ee\r\nContent-Type:\ - \ multipart/mixed; boundary=changesetresponse_396c9cd4-ffd3-4987-9186-9b01e674956e\r\ - \n\r\n--changesetresponse_396c9cd4-ffd3-4987-9186-9b01e674956e\r\nContent-Type:\ + string: "--batchresponse_e10cce8b-a1f5-471b-a7c2-52aff5dadef0\r\nContent-Type:\ + \ multipart/mixed; boundary=changesetresponse_b067fc38-3d15-4873-ae4f-7b3ef1d0644c\r\ + \n\r\n--changesetresponse_b067fc38-3d15-4873-ae4f-7b3ef1d0644c\r\nContent-Type:\ \ application/http\r\nContent-Transfer-Encoding: binary\r\n\r\nHTTP/1.1 204\ \ No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control: no-cache\r\ - \nDataServiceVersion: 1.0;\r\nETag: W/\"datetime'2020-12-18T15%3A42%3A27.3732081Z'\"\ - \r\n\r\n\r\n--changesetresponse_396c9cd4-ffd3-4987-9186-9b01e674956e--\r\n\ - --batchresponse_c4ec0069-d51f-4153-9ed4-a3a6636741ee--\r\n" + \nDataServiceVersion: 1.0;\r\nETag: W/\"datetime'2021-04-30T17%3A28%3A17.3785291Z'\"\ + \r\n\r\n\r\n--changesetresponse_b067fc38-3d15-4873-ae4f-7b3ef1d0644c--\r\n\ + --batchresponse_e10cce8b-a1f5-471b-a7c2-52aff5dadef0--\r\n" headers: cache-control: - no-cache content-type: - - multipart/mixed; boundary=batchresponse_c4ec0069-d51f-4153-9ed4-a3a6636741ee + - multipart/mixed; boundary=batchresponse_e10cce8b-a1f5-471b-a7c2-52aff5dadef0 date: - - Fri, 18 Dec 2020 15:42:27 GMT + - Fri, 30 Apr 2021 17:28:17 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -224,27 +225,27 @@ interactions: DataServiceVersion: - '3.0' Date: - - Fri, 18 Dec 2020 15:42:27 GMT + - Fri, 30 Apr 2021 17:28:17 GMT User-Agent: - - azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 18 Dec 2020 15:42:27 GMT + - Fri, 30 Apr 2021 17:28:17 GMT x-ms-version: - '2019-02-02' method: GET uri: https://fake_table_account.table.core.windows.net/uttablef0c10dba(PartitionKey='001',RowKey='batch_update') response: body: - string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttablef0c10dba/@Element","odata.etag":"W/\"datetime''2020-12-18T15%3A42%3A27.3732081Z''\"","PartitionKey":"001","RowKey":"batch_update","Timestamp":"2020-12-18T15:42:27.3732081Z","test":true,"test2":"value1","test3":3,"test4":1234567890,"test5@odata.type":"Edm.DateTime","test5":"2020-12-18T15:42:26Z"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttablef0c10dba/@Element","odata.etag":"W/\"datetime''2021-04-30T17%3A28%3A17.3785291Z''\"","PartitionKey":"001","RowKey":"batch_update","Timestamp":"2021-04-30T17:28:17.3785291Z","test":true,"test2":"value1","test3":3,"test4":1234567890,"test5@odata.type":"Edm.DateTime","test5":"2021-04-30T21:28:16.696944Z","test6@odata.type":"Edm.Int64","test6":"1099511627776"}' headers: cache-control: - no-cache content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Fri, 18 Dec 2020 15:42:27 GMT + - Fri, 30 Apr 2021 17:28:17 GMT etag: - - W/"datetime'2020-12-18T15%3A42%3A27.3732081Z'" + - W/"datetime'2021-04-30T17%3A28%3A17.3785291Z'" server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -268,11 +269,11 @@ interactions: Content-Length: - '0' Date: - - Fri, 18 Dec 2020 15:42:27 GMT + - Fri, 30 Apr 2021 17:28:17 GMT User-Agent: - - azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 18 Dec 2020 15:42:27 GMT + - Fri, 30 Apr 2021 17:28:17 GMT x-ms-version: - '2019-02-02' method: DELETE @@ -286,7 +287,7 @@ interactions: content-length: - '0' date: - - Fri, 18 Dec 2020 15:42:27 GMT + - Fri, 30 Apr 2021 17:28:17 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 x-content-type-options: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update_if_doesnt_match.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update_if_doesnt_match.yaml index b26bbb1d39a0..f6b0a50f98ff 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update_if_doesnt_match.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update_if_doesnt_match.yaml @@ -15,11 +15,11 @@ interactions: DataServiceVersion: - '3.0' Date: - - Thu, 08 Apr 2021 14:34:33 GMT + - Fri, 30 Apr 2021 17:28:17 GMT User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:34:33 GMT + - Fri, 30 Apr 2021 17:28:17 GMT x-ms-version: - '2019-02-02' method: POST @@ -33,7 +33,7 @@ interactions: content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:18 GMT location: - https://fake_table_account.table.core.windows.net/Tables('uttable3741440') server: @@ -70,27 +70,27 @@ interactions: DataServiceVersion: - '3.0' Date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:18 GMT User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:18 GMT x-ms-version: - '2019-02-02' method: POST uri: https://fake_table_account.table.core.windows.net/uttable3741440 response: body: - string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable3741440/@Element","odata.etag":"W/\"datetime''2021-04-08T14%3A34%3A34.7905688Z''\"","PartitionKey":"pk3741440","RowKey":"rk3741440","Timestamp":"2021-04-08T14:34:34.7905688Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable3741440/@Element","odata.etag":"W/\"datetime''2021-04-30T17%3A28%3A18.9629364Z''\"","PartitionKey":"pk3741440","RowKey":"rk3741440","Timestamp":"2021-04-30T17:28:18.9629364Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' headers: cache-control: - no-cache content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:18 GMT etag: - - W/"datetime'2021-04-08T14%3A34%3A34.7905688Z'" + - W/"datetime'2021-04-30T17%3A28%3A18.9629364Z'" location: - https://fake_table_account.table.core.windows.net/uttable3741440(PartitionKey='pk3741440',RowKey='rk3741440') server: @@ -105,66 +105,66 @@ interactions: code: 201 message: Created - request: - body: "--batch_bf5de0d7-f672-4b4d-ba1d-7134175f3b57\r\nContent-Type: multipart/mixed;\ - \ boundary=changeset_86cdca4b-c0ec-4473-af59-4ed225930554\r\n\r\n--changeset_86cdca4b-c0ec-4473-af59-4ed225930554\r\ + body: "--batch_f49c788b-f401-4913-9751-fe7882ba2633\r\nContent-Type: multipart/mixed;\ + \ boundary=changeset_e9b74c35-7eeb-48ed-bb56-f1c4a250e143\r\n\r\n--changeset_e9b74c35-7eeb-48ed-bb56-f1c4a250e143\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ \ 0\r\n\r\nPATCH https://seankaneprim.table.core.windows.net/uttable3741440(PartitionKey='pk3741440',RowKey='rk3741440')\ \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nIf-Match:\ \ W/\"datetime'2012-06-15T22%3A51%3A44.9662825Z'\"\r\nContent-Type: application/json\r\ - \nAccept: application/json\r\nContent-Length: 358\r\nx-ms-date: Thu, 08 Apr\ - \ 2021 14:34:34 GMT\r\nDate: Thu, 08 Apr 2021 14:34:34 GMT\r\nx-ms-client-request-id:\ - \ 89c550b0-9877-11eb-b445-58961df361ce\r\n\r\n{\"PartitionKey\": \"pk3741440\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"RowKey\": \"rk3741440\", \"\ - RowKey@odata.type\": \"Edm.String\", \"age\": \"abc\", \"age@odata.type\": \"\ - Edm.String\", \"sex\": \"female\", \"sex@odata.type\": \"Edm.String\", \"sign\"\ - : \"aquarius\", \"sign@odata.type\": \"Edm.String\", \"birthday\": \"1991-10-04T00:00:00.000000Z\"\ - , \"birthday@odata.type\": \"Edm.DateTime\"}\r\n--changeset_86cdca4b-c0ec-4473-af59-4ed225930554--\r\ - \n\r\n--batch_bf5de0d7-f672-4b4d-ba1d-7134175f3b57--\r\n" + \nAccept: application/json\r\nContent-Length: 358\r\nx-ms-date: Fri, 30 Apr\ + \ 2021 17:28:18 GMT\r\nDate: Fri, 30 Apr 2021 17:28:18 GMT\r\n\r\n{\"PartitionKey\"\ + : \"pk3741440\", \"PartitionKey@odata.type\": \"Edm.String\", \"RowKey\": \"\ + rk3741440\", \"RowKey@odata.type\": \"Edm.String\", \"age\": \"abc\", \"age@odata.type\"\ + : \"Edm.String\", \"sex\": \"female\", \"sex@odata.type\": \"Edm.String\", \"\ + sign\": \"aquarius\", \"sign@odata.type\": \"Edm.String\", \"birthday\": \"\ + 1991-10-04T00:00:00.000000Z\", \"birthday@odata.type\": \"Edm.DateTime\"}\r\n\ + --changeset_e9b74c35-7eeb-48ed-bb56-f1c4a250e143--\r\n\r\n--batch_f49c788b-f401-4913-9751-fe7882ba2633--\r\ + \n" headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive Content-Length: - - '1183' + - '1121' Content-Type: - - multipart/mixed; boundary=batch_bf5de0d7-f672-4b4d-ba1d-7134175f3b57 + - multipart/mixed; boundary=batch_f49c788b-f401-4913-9751-fe7882ba2633 DataServiceVersion: - '3.0' Date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:18 GMT MaxDataServiceVersion: - 3.0;NetFx User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:18 GMT x-ms-version: - '2019-02-02' method: POST uri: https://fake_table_account.table.core.windows.net/$batch response: body: - string: "--batchresponse_266fa9fd-79a3-4b5a-8619-f66c58ccde45\r\nContent-Type:\ - \ multipart/mixed; boundary=changesetresponse_3a8cfc52-2dc4-400e-b3ad-dce188bdbc61\r\ - \n\r\n--changesetresponse_3a8cfc52-2dc4-400e-b3ad-dce188bdbc61\r\nContent-Type:\ + string: "--batchresponse_0adfe3a2-d7ef-480e-9e51-fb0671eab08a\r\nContent-Type:\ + \ multipart/mixed; boundary=changesetresponse_028fb7ef-954b-494a-a1c2-a43ffe5de90c\r\ + \n\r\n--changesetresponse_028fb7ef-954b-494a-a1c2-a43ffe5de90c\r\nContent-Type:\ \ application/http\r\nContent-Transfer-Encoding: binary\r\n\r\nHTTP/1.1 412\ \ Precondition Failed\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ \ no-cache\r\nDataServiceVersion: 3.0;\r\nContent-Type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8\r\ \n\r\n{\"odata.error\":{\"code\":\"UpdateConditionNotSatisfied\",\"message\"\ :{\"lang\":\"en-US\",\"value\":\"The update condition specified in the request\ - \ was not satisfied.\\nRequestId:16996ca9-f002-006a-3e84-2c020c000000\\nTime:2021-04-08T14:34:34.9466810Z\"\ - }}}\r\n--changesetresponse_3a8cfc52-2dc4-400e-b3ad-dce188bdbc61--\r\n--batchresponse_266fa9fd-79a3-4b5a-8619-f66c58ccde45--\r\ + \ was not satisfied.\\nRequestId:22177651-4002-001d-31e6-3dd798000000\\nTime:2021-04-30T17:28:19.1941023Z\"\ + }}}\r\n--changesetresponse_028fb7ef-954b-494a-a1c2-a43ffe5de90c--\r\n--batchresponse_0adfe3a2-d7ef-480e-9e51-fb0671eab08a--\r\ \n" headers: cache-control: - no-cache content-type: - - multipart/mixed; boundary=batchresponse_266fa9fd-79a3-4b5a-8619-f66c58ccde45 + - multipart/mixed; boundary=batchresponse_0adfe3a2-d7ef-480e-9e51-fb0671eab08a date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:18 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -188,27 +188,27 @@ interactions: DataServiceVersion: - '3.0' Date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:19 GMT User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:19 GMT x-ms-version: - '2019-02-02' method: GET uri: https://fake_table_account.table.core.windows.net/uttable3741440(PartitionKey='pk3741440',RowKey='rk3741440') response: body: - string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable3741440/@Element","odata.etag":"W/\"datetime''2021-04-08T14%3A34%3A34.7905688Z''\"","PartitionKey":"pk3741440","RowKey":"rk3741440","Timestamp":"2021-04-08T14:34:34.7905688Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable3741440/@Element","odata.etag":"W/\"datetime''2021-04-30T17%3A28%3A18.9629364Z''\"","PartitionKey":"pk3741440","RowKey":"rk3741440","Timestamp":"2021-04-30T17:28:18.9629364Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' headers: cache-control: - no-cache content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:18 GMT etag: - - W/"datetime'2021-04-08T14%3A34%3A34.7905688Z'" + - W/"datetime'2021-04-30T17%3A28%3A18.9629364Z'" server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -232,11 +232,11 @@ interactions: Content-Length: - '0' Date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:19 GMT User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:19 GMT x-ms-version: - '2019-02-02' method: DELETE @@ -250,7 +250,7 @@ interactions: content-length: - '0' date: - - Thu, 08 Apr 2021 14:34:34 GMT + - Fri, 30 Apr 2021 17:28:19 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 x-content-type-options: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update_if_match.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update_if_match.yaml index 6545376c4b35..4b42eb71e070 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update_if_match.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_update_if_match.yaml @@ -15,11 +15,11 @@ interactions: DataServiceVersion: - '3.0' Date: - - Thu, 08 Apr 2021 14:31:32 GMT + - Fri, 30 Apr 2021 17:28:19 GMT User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:31:32 GMT + - Fri, 30 Apr 2021 17:28:19 GMT x-ms-version: - '2019-02-02' method: POST @@ -33,7 +33,7 @@ interactions: content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT location: - https://fake_table_account.table.core.windows.net/Tables('uttable7e2c1154') server: @@ -70,27 +70,27 @@ interactions: DataServiceVersion: - '3.0' Date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT x-ms-version: - '2019-02-02' method: POST uri: https://fake_table_account.table.core.windows.net/uttable7e2c1154 response: body: - string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable7e2c1154/@Element","odata.etag":"W/\"datetime''2021-04-08T14%3A31%3A33.9602476Z''\"","PartitionKey":"pk7e2c1154","RowKey":"rk7e2c1154","Timestamp":"2021-04-08T14:31:33.9602476Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable7e2c1154/@Element","odata.etag":"W/\"datetime''2021-04-30T17%3A28%3A20.6671035Z''\"","PartitionKey":"pk7e2c1154","RowKey":"rk7e2c1154","Timestamp":"2021-04-30T17:28:20.6671035Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' headers: cache-control: - no-cache content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT etag: - - W/"datetime'2021-04-08T14%3A31%3A33.9602476Z'" + - W/"datetime'2021-04-30T17%3A28%3A20.6671035Z'" location: - https://fake_table_account.table.core.windows.net/uttable7e2c1154(PartitionKey='pk7e2c1154',RowKey='rk7e2c1154') server: @@ -105,63 +105,63 @@ interactions: code: 201 message: Created - request: - body: "--batch_2de12e6e-62d7-4c7d-865a-2f61b4d5ab61\r\nContent-Type: multipart/mixed;\ - \ boundary=changeset_6caed5cb-1cc7-4ca5-9d4d-446ec5e23e4c\r\n\r\n--changeset_6caed5cb-1cc7-4ca5-9d4d-446ec5e23e4c\r\ + body: "--batch_b576f05d-3be7-4e3f-b6c9-51f7dc55ed26\r\nContent-Type: multipart/mixed;\ + \ boundary=changeset_bc54d89d-04c1-4253-986e-32d2bff993c1\r\n\r\n--changeset_bc54d89d-04c1-4253-986e-32d2bff993c1\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ \ 0\r\n\r\nPUT https://seankaneprim.table.core.windows.net/uttable7e2c1154(PartitionKey='pk7e2c1154',RowKey='rk7e2c1154')\ \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nIf-Match:\ - \ W/\"datetime'2021-04-08T14%3A31%3A33.9602476Z'\"\r\nContent-Type: application/json\r\ - \nAccept: application/json\r\nContent-Length: 360\r\nx-ms-date: Thu, 08 Apr\ - \ 2021 14:31:33 GMT\r\nDate: Thu, 08 Apr 2021 14:31:33 GMT\r\nx-ms-client-request-id:\ - \ 1e02b4f6-9877-11eb-8ccf-58961df361ce\r\n\r\n{\"PartitionKey\": \"pk7e2c1154\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"RowKey\": \"rk7e2c1154\", \"\ - RowKey@odata.type\": \"Edm.String\", \"age\": \"abc\", \"age@odata.type\": \"\ - Edm.String\", \"sex\": \"female\", \"sex@odata.type\": \"Edm.String\", \"sign\"\ - : \"aquarius\", \"sign@odata.type\": \"Edm.String\", \"birthday\": \"1991-10-04T00:00:00.000000Z\"\ - , \"birthday@odata.type\": \"Edm.DateTime\"}\r\n--changeset_6caed5cb-1cc7-4ca5-9d4d-446ec5e23e4c--\r\ - \n\r\n--batch_2de12e6e-62d7-4c7d-865a-2f61b4d5ab61--\r\n" + \ W/\"datetime'2021-04-30T17%3A28%3A20.6671035Z'\"\r\nContent-Type: application/json\r\ + \nAccept: application/json\r\nContent-Length: 360\r\nx-ms-date: Fri, 30 Apr\ + \ 2021 17:28:20 GMT\r\nDate: Fri, 30 Apr 2021 17:28:20 GMT\r\n\r\n{\"PartitionKey\"\ + : \"pk7e2c1154\", \"PartitionKey@odata.type\": \"Edm.String\", \"RowKey\": \"\ + rk7e2c1154\", \"RowKey@odata.type\": \"Edm.String\", \"age\": \"abc\", \"age@odata.type\"\ + : \"Edm.String\", \"sex\": \"female\", \"sex@odata.type\": \"Edm.String\", \"\ + sign\": \"aquarius\", \"sign@odata.type\": \"Edm.String\", \"birthday\": \"\ + 1991-10-04T00:00:00.000000Z\", \"birthday@odata.type\": \"Edm.DateTime\"}\r\n\ + --changeset_bc54d89d-04c1-4253-986e-32d2bff993c1--\r\n\r\n--batch_b576f05d-3be7-4e3f-b6c9-51f7dc55ed26--\r\ + \n" headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive Content-Length: - - '1186' + - '1124' Content-Type: - - multipart/mixed; boundary=batch_2de12e6e-62d7-4c7d-865a-2f61b4d5ab61 + - multipart/mixed; boundary=batch_b576f05d-3be7-4e3f-b6c9-51f7dc55ed26 DataServiceVersion: - '3.0' Date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT MaxDataServiceVersion: - 3.0;NetFx User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT x-ms-version: - '2019-02-02' method: POST uri: https://fake_table_account.table.core.windows.net/$batch response: body: - string: "--batchresponse_ba16c55e-4a74-43d8-aad7-712bd9989333\r\nContent-Type:\ - \ multipart/mixed; boundary=changesetresponse_a5d23f2c-60d9-47d1-add1-824421d5633c\r\ - \n\r\n--changesetresponse_a5d23f2c-60d9-47d1-add1-824421d5633c\r\nContent-Type:\ + string: "--batchresponse_dffe0b7b-6975-4fd8-aeda-50178864b078\r\nContent-Type:\ + \ multipart/mixed; boundary=changesetresponse_4e31850d-2e18-44fa-b7ff-be4ca760a088\r\ + \n\r\n--changesetresponse_4e31850d-2e18-44fa-b7ff-be4ca760a088\r\nContent-Type:\ \ application/http\r\nContent-Transfer-Encoding: binary\r\n\r\nHTTP/1.1 204\ \ No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control: no-cache\r\ - \nDataServiceVersion: 1.0;\r\nETag: W/\"datetime'2021-04-08T14%3A31%3A34.181982Z'\"\ - \r\n\r\n\r\n--changesetresponse_a5d23f2c-60d9-47d1-add1-824421d5633c--\r\n\ - --batchresponse_ba16c55e-4a74-43d8-aad7-712bd9989333--\r\n" + \nDataServiceVersion: 1.0;\r\nETag: W/\"datetime'2021-04-30T17%3A28%3A20.8460096Z'\"\ + \r\n\r\n\r\n--changesetresponse_4e31850d-2e18-44fa-b7ff-be4ca760a088--\r\n\ + --batchresponse_dffe0b7b-6975-4fd8-aeda-50178864b078--\r\n" headers: cache-control: - no-cache content-type: - - multipart/mixed; boundary=batchresponse_ba16c55e-4a74-43d8-aad7-712bd9989333 + - multipart/mixed; boundary=batchresponse_dffe0b7b-6975-4fd8-aeda-50178864b078 date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -185,27 +185,27 @@ interactions: DataServiceVersion: - '3.0' Date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT x-ms-version: - '2019-02-02' method: GET uri: https://fake_table_account.table.core.windows.net/uttable7e2c1154(PartitionKey='pk7e2c1154',RowKey='rk7e2c1154') response: body: - string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable7e2c1154/@Element","odata.etag":"W/\"datetime''2021-04-08T14%3A31%3A34.181982Z''\"","PartitionKey":"pk7e2c1154","RowKey":"rk7e2c1154","Timestamp":"2021-04-08T14:31:34.181982Z","age":"abc","birthday@odata.type":"Edm.DateTime","birthday":"1991-10-04T00:00:00Z","sex":"female","sign":"aquarius"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable7e2c1154/@Element","odata.etag":"W/\"datetime''2021-04-30T17%3A28%3A20.8460096Z''\"","PartitionKey":"pk7e2c1154","RowKey":"rk7e2c1154","Timestamp":"2021-04-30T17:28:20.8460096Z","age":"abc","birthday@odata.type":"Edm.DateTime","birthday":"1991-10-04T00:00:00Z","sex":"female","sign":"aquarius"}' headers: cache-control: - no-cache content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT etag: - - W/"datetime'2021-04-08T14%3A31%3A34.181982Z'" + - W/"datetime'2021-04-30T17%3A28%3A20.8460096Z'" server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -229,11 +229,11 @@ interactions: Content-Length: - '0' Date: - - Thu, 08 Apr 2021 14:31:34 GMT + - Fri, 30 Apr 2021 17:28:20 GMT User-Agent: - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 08 Apr 2021 14:31:34 GMT + - Fri, 30 Apr 2021 17:28:20 GMT x-ms-version: - '2019-02-02' method: DELETE @@ -247,7 +247,7 @@ interactions: content-length: - '0' date: - - Thu, 08 Apr 2021 14:31:33 GMT + - Fri, 30 Apr 2021 17:28:20 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 x-content-type-options: diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch.py b/sdk/tables/azure-data-tables/tests/test_table_batch.py index bddbd0875602..0c81ec74ed5c 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch.py @@ -254,6 +254,7 @@ def test_batch_update(self, tables_storage_account_name, tables_primary_storage_ entity.test3 = 3 entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() + entity.test6 = (2 ** 40, "EdmType.INT64") self.table.create_entity(entity) entity = self.table.get_entity(u'001', u'batch_update') From 7789f68c992195ae035017e3705efdd8b45457bf Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 3 May 2021 10:22:49 -0400 Subject: [PATCH 7/8] addressing annas comments --- .../azure-data-tables/azure/data/tables/_serialize.py | 8 -------- sdk/tables/azure-data-tables/tests/test_table_batch.py | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py b/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py index 3c02dd354226..ae386f6fa87f 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py @@ -185,14 +185,6 @@ def _to_entity_none(value): # pylint: disable=unused-argument EdmType.INT32: _to_entity_int32, EdmType.INT64: _to_entity_int64, EdmType.STRING: _to_entity_str, - "EdmType.BINARY": _to_entity_binary, - "EdmType.BOOLEAN": _to_entity_bool, - "EdmType.DATETIME": _to_entity_datetime, - "EdmType.DOUBLE": _to_entity_float, - "EdmType.GUID": _to_entity_guid, - "EdmType.INT32": _to_entity_int32, - "EdmType.INT64": _to_entity_int64, - "EdmType.STRING": _to_entity_str, } diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch.py b/sdk/tables/azure-data-tables/tests/test_table_batch.py index 0c81ec74ed5c..1aa18cfbecef 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch.py @@ -254,7 +254,7 @@ def test_batch_update(self, tables_storage_account_name, tables_primary_storage_ entity.test3 = 3 entity.test4 = EntityProperty(1234567890, EdmType.INT32) entity.test5 = datetime.utcnow() - entity.test6 = (2 ** 40, "EdmType.INT64") + entity.test6 = (2 ** 40, "Edm.Int64") self.table.create_entity(entity) entity = self.table.get_entity(u'001', u'batch_update') From 8243e1fe9a85d8e171ddaec0d1995457c9263064 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 3 May 2021 11:25:28 -0400 Subject: [PATCH 8/8] removing unnecessary import --- sdk/tables/azure-data-tables/azure/data/tables/_serialize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py b/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py index ae386f6fa87f..5a424985405f 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_serialize.py @@ -15,7 +15,7 @@ from azure.core import MatchConditions from azure.core.exceptions import raise_with_traceback -from ._entity import EdmType, EntityProperty +from ._entity import EdmType from ._common_conversion import _encode_base64, _to_utc_datetime from ._error import _ERROR_VALUE_TOO_LARGE, _ERROR_TYPE_NOT_SUPPORTED