Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Json_Array: Convert database null to PHP null instead of empty array #538

Closed
wants to merge 2 commits into from

4 participants

@doctrinebot
Collaborator

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DBAL-828

We use Jira to track the state of pull requests and the versions they got
included in.

@Ocramius
Owner

@localheinz saw this - waiting for @deeky666's opinion first.

@deeky666 deeky666 commented on the diff
lib/Doctrine/DBAL/Types/JsonArrayType.php
@@ -55,7 +55,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
- return array();
+ return null;
@deeky666 Collaborator
deeky666 added a note

Not sure if we can change this in 2.x as it surely breaks BC. @beberlei thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@deeky666
Collaborator

To preserve BC we cannot change that in 2.x unfortunately but instead have to address this in 3.0 as @guilhermeblanco pointed out in doctrine/doctrine2#968.
Closing this for now and keeping the issue open on JIRA marking it for 3.0

@deeky666 deeky666 closed this
@localheinz localheinz deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  lib/Doctrine/DBAL/Types/JsonArrayType.php
@@ -55,7 +55,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
- return array();
+ return null;
@deeky666 Collaborator
deeky666 added a note

Not sure if we can change this in 2.x as it surely breaks BC. @beberlei thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
$value = (is_resource($value)) ? stream_get_contents($value) : $value;
View
2  tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
@@ -45,7 +45,7 @@ public function testReturnsSQLDeclaration()
public function testJsonNullConvertsToPHPValue()
{
- $this->assertSame(array(), $this->type->convertToPHPValue(null, $this->platform));
+ $this->assertNull($this->type->convertToPHPValue(null, $this->platform));
}
public function testJsonStringConvertsToPHPValue()
Something went wrong with that request. Please try again.