diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a1d79f7da..fcaf5d087 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1442,6 +1442,8 @@ class DboSource extends DataSource { $data = ' ' . $value; } elseif ($value === null || (is_array($value) && empty($value))) { $data = $this->name($key) . ' IS NULL'; + } elseif ($value === false || $value === true) { + $data = $this->name($key) . " = " . $this->boolean($value); } elseif ($value === '') { $data = $this->name($key) . " = ''"; } elseif (preg_match('/^([a-z]*\\([a-z0-9]*\\)\\x20?|(?:' . join('\\x20)|(?:', $this->__sqlOps) . '\\x20)|<=?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)?(.*)/i', $value, $match)) { @@ -1563,7 +1565,6 @@ class DboSource extends DataSource { } else { $dir = ''; } - $key = trim($this->name(trim($key)) . ' ' . trim($dir)); } $order[] = $this->order($key . $value); diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 3fa1c71b8..1d805654a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -702,6 +702,15 @@ class DboSourceTest extends UnitTestCase { $result = $this->db->conditions(array('published' => 1, 'or' => array('score' => '< 2', array('score' => '> 20')) )); $expected = " WHERE `published` = 1 AND (`score` < 2) OR (`score` > 20)"; $this->assertEqual($result, $expected); + + $result = $this->db->conditions(array(array('Project.removed' => false))); + $this->assertPattern('/^\s*WHERE\s+`Project`.`removed`\s+=\s+0\s*$/', $result); + + $result = $this->db->conditions(array(array('Project.removed' => true))); + $this->assertPattern('/^\s*WHERE\s+`Project`.`removed`\s+=\s+1\s*$/', $result); + + $result = $this->db->conditions(array(array('Project.removed' => null))); + $this->assertPattern('/^\s*WHERE\s+`Project`.`removed`\s+IS\s+NULL\s*$/', $result); } function testFieldParsing() {