diff --git a/internal/services/storage/storage_table_entities_data_source.go b/internal/services/storage/storage_table_entities_data_source.go index 8d5364765a65..27fdb0bb954e 100644 --- a/internal/services/storage/storage_table_entities_data_source.go +++ b/internal/services/storage/storage_table_entities_data_source.go @@ -168,8 +168,8 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo result := TableEntitiyDataSourceModel{} + properties := map[string]interface{}{} for k, v := range entity { - properties := map[string]interface{}{} if k == "PartitionKey" { result.PartitionKey = v.(string) continue @@ -200,7 +200,6 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo } properties[k+"@odata.type"] = dtype - result.Properties = properties } else { // special handling for property types that do not require the annotation to be present // https://docs.microsoft.com/en-us/rest/api/storageservices/payload-format-for-table-service-operations#property-types-in-a-json-feed @@ -223,9 +222,9 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo default: log.Printf("[WARN] key %q with unexpected type %T", k, c) } - result.Properties = properties } } + result.Properties = properties return result } diff --git a/internal/services/storage/storage_table_entities_data_source_test.go b/internal/services/storage/storage_table_entities_data_source_test.go index 38da64d33089..ac9dda3b08f9 100644 --- a/internal/services/storage/storage_table_entities_data_source_test.go +++ b/internal/services/storage/storage_table_entities_data_source_test.go @@ -21,6 +21,7 @@ func TestAccDataSourceStorageTableEntities_basic(t *testing.T) { Config: StorageTableEntitiesDataSource{}.basicWithDataSource(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key("items.#").HasValue("2"), + check.That(data.ResourceName).Key("items.0.properties.%").HasValue("2"), ), }, }) @@ -74,7 +75,8 @@ resource "azurerm_storage_table_entity" "test" { row_key = "testrow" entity = { - testkey = "testval" + testkey1 = "testval11" + testkey2 = "testval12" } } @@ -86,7 +88,8 @@ resource "azurerm_storage_table_entity" "test2" { row_key = "testrow2" entity = { - testkey = "testval2" + testkey1 = "testval21" + testkey2 = "testval22" } } @@ -98,7 +101,8 @@ resource "azurerm_storage_table_entity" "testselector" { row_key = "testrow" entity = { - testkey = "testval" + testkey1 = "testval31" + testkey2 = "testval32" testselector = "testselectorval" } }