diff --git a/lib/Doctrine/DBAL/Types/JsonArrayType.php b/lib/Doctrine/DBAL/Types/JsonArrayType.php index d54ab166c03..79c3259411b 100644 --- a/lib/Doctrine/DBAL/Types/JsonArrayType.php +++ b/lib/Doctrine/DBAL/Types/JsonArrayType.php @@ -54,7 +54,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) */ public function convertToPHPValue($value, AbstractPlatform $platform) { - if ($value === null) { + if ($value === null || $value === '') { return array(); } diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php index 4d172a24242..0d1d29e7db0 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php @@ -48,6 +48,11 @@ public function testJsonNullConvertsToPHPValue() $this->assertSame(array(), $this->type->convertToPHPValue(null, $this->platform)); } + public function testJsonEmptyStringConvertsToPHPValue() + { + $this->assertSame(array(), $this->type->convertToPHPValue('', $this->platform)); + } + public function testJsonStringConvertsToPHPValue() { $value = array('foo' => 'bar', 'bar' => 'foo');