From 22ad15166f2c879ee03dbc09a8a4cd2fe5e8626d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 4 Mar 2014 11:15:00 +0100 Subject: [PATCH 1/6] Test: Add failing test --- .../ORM/Functional/Ticket/DDC446Test.php | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php new file mode 100644 index 00000000000..594f04f8c49 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php @@ -0,0 +1,72 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC446Entity'), + )); + } + + public function testNullableJsonArrayIsNull() + { + $entity = new DDC446Entity(); + + $this->_em->persist($entity); + + $this->_em->flush(); + $this->_em->clear(); + + $entity = $this->_em->find( + DDC446Entity::class, + $entity->getId() + ); + + $this->assertInstanceOf(DDC446Entity::class, $entity); + $this->assertNull($entity->getData()); + } +} + + +/** + * @Entity + * @Table(name = "ddc446") + */ +class DDC446Entity +{ + /** + * @Id + * @Column( + * name = "id", + * type = "integer" + * ) + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @Column( + * name = "data", + * type = "json_array", + * nullable = true + * ) + */ + public $data; + + public function getId() + { + return $this->id; + } + + public function getData() + { + return $this->data; + } +} From 0d8b293735a1bdda4982d7321440fa42da866f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 4 Mar 2014 11:42:31 +0100 Subject: [PATCH 2/6] Composer: Update doctrine/dbal dependency --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4b0d449f02e..0a8f6a99b04 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": ">=5.3.2", "ext-pdo": "*", "doctrine/collections": "~1.1", - "doctrine/dbal": ">=2.5-dev,<2.6-dev", + "doctrine/dbal": "dev-bugfix/nullable-json-array-mapped-to-empty-array", "symfony/console": "2.*" }, "require-dev": { @@ -26,6 +26,12 @@ "suggest": { "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/localheinz/dbal" + } + ], "autoload": { "psr-0": { "Doctrine\\ORM\\": "lib/" } }, From af19554e9e153e7ae61dbb2f8c939d875f6747e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 4 Mar 2014 11:48:24 +0100 Subject: [PATCH 3/6] Fix: Remove required, add import --- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php index 594f04f8c49..7a239f38d8e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php @@ -2,14 +2,14 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -require_once __DIR__ . '/../../../TestInit.php'; +use Doctrine\Tests\OrmFunctionalTestCase; -class DDC446Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC446Test extends OrmFunctionalTestCase { public function setUp() { parent::setUp(); - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC446Entity'), )); From 1eb3099b21ea51932c5762f7f3c64404807a7312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Wed, 5 Mar 2014 22:50:39 +0100 Subject: [PATCH 4/6] Composer: Maybe this helps --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0a8f6a99b04..04f1234d16e 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "repositories": [ { "type": "vcs", - "url": "https://github.com/localheinz/dbal" + "url": "https://github.com/localheinz/dbal.git" } ], "autoload": { From 977cddca7564a95affd159da732ba19a38fb4beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Thu, 6 Mar 2014 08:43:51 +0100 Subject: [PATCH 5/6] Fix: Remove class keyword usage (PHP5.5) --- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php index 7a239f38d8e..a207069b6a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php @@ -29,7 +29,7 @@ public function testNullableJsonArrayIsNull() $entity->getId() ); - $this->assertInstanceOf(DDC446Entity::class, $entity); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC446Entity', $entity); $this->assertNull($entity->getData()); } } From 4bf06b17ac75c428a45fc7fa9d1a307ecd86eb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Thu, 6 Mar 2014 11:10:56 +0100 Subject: [PATCH 6/6] Fix: Remove class keyword --- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php index a207069b6a0..65d5f060c7c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC446Test.php @@ -25,7 +25,7 @@ public function testNullableJsonArrayIsNull() $this->_em->clear(); $entity = $this->_em->find( - DDC446Entity::class, + __NAMESPACE__ . '\DDC446Entity', $entity->getId() );