Skip to content

Commit

Permalink
Merge pull request #7585 from cakephp/issue-7583
Browse files Browse the repository at this point in the history
Allow NULL in boolean types.
  • Loading branch information
dereuromark committed Oct 21, 2015
2 parents 5183d95 + 0f6c391 commit 2cba8e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Database/Type/BoolType.php
Expand Up @@ -36,7 +36,7 @@ class BoolType extends Type
*/
public function toDatabase($value, Driver $driver)
{
if ($value === true || $value === false) {
if ($value === true || $value === false || $value === null) {
return $value;
}

Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/Database/TypeTest.php
Expand Up @@ -272,6 +272,7 @@ public function testBooleanToDatabase()
$type = Type::build('boolean');
$driver = $this->getMock('\Cake\Database\Driver');

$this->assertNull($type->toDatabase(null, $driver));
$this->assertTrue($type->toDatabase(true, $driver));
$this->assertFalse($type->toDatabase(false, $driver));
$this->assertTrue($type->toDatabase(1, $driver));
Expand Down

0 comments on commit 2cba8e6

Please sign in to comment.