Skip to content

Commit

Permalink
Allow NULL in boolean types.
Browse files Browse the repository at this point in the history
BOOLEAN columns can be nullable, so we should allow that state.

Refs #7583
  • Loading branch information
markstory committed Oct 20, 2015
1 parent 9f90a04 commit 0f6c391
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 0f6c391

Please sign in to comment.