diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 82dfeeb1e..7893d7413 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -1836,6 +1836,8 @@ class DboSource extends DataSource { if ($quoteValues) { $update .= $this->value($value, $model->getColumnType($field)); + } elseif ($model->getColumnType($field) == 'boolean') { + $update .= $this->boolean($value, true); } elseif (!$alias) { $update .= str_replace($quotedAlias . '.', '', str_replace( $model->alias . '.', '', $value diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 722512f90..cbb74e32d 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -6605,4 +6605,52 @@ class ModelWriteTest extends BaseModelTest { $this->assertEquals($expected, $result); } +/** + * testUpdateAllBoolean + * + * return @void + */ + public function testUpdateAllBoolean() { + $this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio'); + $TestModel = new Item(); + $result = $TestModel->updateAll(array('published' => true)); + $this->assertTrue($result); + + $result = $TestModel->find('first', array('fields' => array('id', 'published'))); + $this->assertEquals(true, $result['Item']['published']); + } + +/** + * testUpdateAllBooleanConditions + * + * return @void + */ + public function testUpdateAllBooleanConditions() { + $this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio'); + $TestModel = new Item(); + + $result = $TestModel->updateAll(array('published' => true), array('Item.id' => 1)); + $this->assertTrue($result); + $result = $TestModel->find('first', array( + 'fields' => array('id', 'published'), + 'conditions' => array('Item.id' => 1))); + $this->assertEquals(true, $result['Item']['published']); + } + +/** + * testUpdateBoolean + * + * return @void + */ + public function testUpdateBoolean() { + $this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio'); + $TestModel = new Item(); + + $result = $TestModel->save(array('published' => true, 'id' => 1)); + $this->assertTrue((boolean)$result); + $result = $TestModel->find('first', array( + 'fields' => array('id', 'published'), + 'conditions' => array('Item.id' => 1))); + $this->assertEquals(true, $result['Item']['published']); + } }