From d126e4396710d4156dacead0b30c9a67689e1965 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 2 Aug 2017 12:35:27 +0200 Subject: [PATCH 1/3] Added mapping for guid type --- .../Serializer/Metadata/Driver/AbstractDoctrineTypeDriver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/JMS/Serializer/Metadata/Driver/AbstractDoctrineTypeDriver.php b/src/JMS/Serializer/Metadata/Driver/AbstractDoctrineTypeDriver.php index cf98643e9..455074d0f 100644 --- a/src/JMS/Serializer/Metadata/Driver/AbstractDoctrineTypeDriver.php +++ b/src/JMS/Serializer/Metadata/Driver/AbstractDoctrineTypeDriver.php @@ -41,6 +41,7 @@ abstract class AbstractDoctrineTypeDriver implements DriverInterface 'string' => 'string', 'text' => 'string', 'blob' => 'string', + 'guid' => 'string', 'integer' => 'integer', 'smallint' => 'integer', From 502d6559a224628e95e9b1dcda0c53350a9bb2db Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 2 Aug 2017 12:58:02 +0200 Subject: [PATCH 2/3] Changed integer id to guid // UUID strategy --- tests/Fixtures/Doctrine/BlogPost.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Fixtures/Doctrine/BlogPost.php b/tests/Fixtures/Doctrine/BlogPost.php index 322d5d486..8a493fa67 100644 --- a/tests/Fixtures/Doctrine/BlogPost.php +++ b/tests/Fixtures/Doctrine/BlogPost.php @@ -35,7 +35,7 @@ class BlogPost { /** - * @ORM\Id @ORM\Column(type="integer") + * @ORM\Id @ORM\Column(type="guid") @ORM\GeneratedValue(strategy="UUID") */ protected $id; From 633803a27966e98629fc42f3dcbb42d7d1279b40 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 2 Aug 2017 12:59:18 +0200 Subject: [PATCH 3/3] Added test if fieldMapping maps a guid as a string --- tests/Metadata/Driver/DoctrineDriverTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Metadata/Driver/DoctrineDriverTest.php b/tests/Metadata/Driver/DoctrineDriverTest.php index 41adbda3c..80845f3e3 100644 --- a/tests/Metadata/Driver/DoctrineDriverTest.php +++ b/tests/Metadata/Driver/DoctrineDriverTest.php @@ -106,6 +106,16 @@ public function testVirtualPropertiesAreNotModified() $this->assertNull($doctrineMetadata->propertyMetadata['ref']->type); } + public function testGuidPropertyIsGivenStringType() + { + $metadata = $this->getMetadata(); + + $this->assertEquals( + array('name' => 'string', 'params' => array()), + $metadata->propertyMetadata['id']->type + ); + } + protected function getEntityManager() { $config = new Configuration();