-
Notifications
You must be signed in to change notification settings - Fork 3k
[Tables] Updating EntityProperty #18177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
b4fc2b7
0a3d6d0
86a7fcb
877c612
ece28c4
96b89ef
2993b3e
7789f68
c3de848
8243e1f
1252af3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,7 +226,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should remove the elif isinstance(value, tuple): # ideally we wouldn't do the instance check at all here....
conv = _EDM_TO_ENTITY_CONVERSIONS.get(value[1])
...
mtype, value = conv(value[0]) |
||
if conv is None: | ||
raise TypeError(_ERROR_TYPE_NOT_SUPPORTED.format(value.type)) | ||
mtype, value = conv(value.value) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,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) | ||
|
@@ -183,10 +183,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 = [('create', entity)] | ||
|
@@ -214,10 +214,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) | ||
|
@@ -249,10 +249,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to either add a test, or modify one of the existing ones to just use naked tuples: |
||
entity.test5 = datetime.utcnow() | ||
self.table.create_entity(entity) | ||
|
||
|
@@ -285,10 +285,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) | ||
|
||
|
@@ -377,10 +377,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 = [] | ||
transaction_count = 0 | ||
|
@@ -423,7 +423,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 = [('upsert', entity, {'mode': UpdateMode.REPLACE})] | ||
|
@@ -453,7 +453,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 = [('upsert', entity, {'mode': UpdateMode.MERGE})] | ||
|
@@ -480,10 +480,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) | ||
|
||
|
@@ -511,10 +511,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) | ||
|
||
transaction_count = 0 | ||
batch = [] | ||
|
@@ -547,10 +547,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' | ||
|
@@ -619,10 +619,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 = [] | ||
|
@@ -814,10 +814,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 = [] | ||
transaction_count = 0 | ||
|
@@ -861,33 +861,3 @@ def test_batch_request_too_large(self, tables_storage_account_name, tables_prima | |
|
||
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 |
Uh oh!
There was an error while loading. Please reload this page.