Skip to content

Commit

Permalink
Marshal non scalar values to null.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Aug 15, 2018
1 parent a7e21d3 commit 399624a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Database/Type/BoolType.php
Expand Up @@ -161,6 +161,9 @@ public function marshal($value)
if ($value === 'false') {
return false;
}
if (!is_scalar($value)) {
return null;
}

return !empty($value);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Type/BoolTypeTest.php
Expand Up @@ -157,7 +157,7 @@ public function testMarshal()
$this->assertFalse($this->type->marshal(0));
$this->assertFalse($this->type->marshal(''));
$this->assertTrue($this->type->marshal('not empty'));
$this->assertTrue($this->type->marshal(['2', '3']));
$this->assertNull($this->type->marshal(['2', '3']));
}

/**
Expand Down

0 comments on commit 399624a

Please sign in to comment.