diff --git a/azure-storage-table/src/Table/Internal/JsonODataReaderWriter.php b/azure-storage-table/src/Table/Internal/JsonODataReaderWriter.php index 58bcc1468..3df49048d 100644 --- a/azure-storage-table/src/Table/Internal/JsonODataReaderWriter.php +++ b/azure-storage-table/src/Table/Internal/JsonODataReaderWriter.php @@ -202,6 +202,8 @@ private function parseOneEntity($rawEntity) $edmType; if (array_key_exists($key . Resources::JSON_ODATA_TYPE_SUFFIX, $rawEntity)) { $edmType = $rawEntity[$key . Resources::JSON_ODATA_TYPE_SUFFIX]; + } elseif (in_array($key, [Resources::JSON_PARTITION_KEY, Resources::JSON_ROW_KEY], true)) { + $edmType = EdmType::STRING; } else { // Guess the property type $edmType = EdmType::propertyType($value); diff --git a/tests/Unit/Table/Internal/JsonODataReaderWriterTest.php b/tests/Unit/Table/Internal/JsonODataReaderWriterTest.php index c7ff42084..16a575893 100644 --- a/tests/Unit/Table/Internal/JsonODataReaderWriterTest.php +++ b/tests/Unit/Table/Internal/JsonODataReaderWriterTest.php @@ -135,6 +135,28 @@ public function testParseEntity() } } + + public function testParseEntityStringKeys() + { + // Setup + $serializer = new JsonODataReaderWriter(); + $expected = TestResources::getExpectedTestEntity('0e123', '123e456'); + $json = TestResources::getEntityMinimalMetaResult('0e123', '123e456'); + + // Test + $actual = $serializer->parseEntity($json); + + // Assert + $this->assertSame( + $expected->getPartitionKey(), + $actual->getPartitionKey() + ); + $this->assertSame( + $expected->getRowKey(), + $actual->getRowKey() + ); + } + public function testParseEntities() { // Setup