Merge pull request #962 from srwebs/feature/empty-bool-operators

Fix: check if bool operators in find conditions are empty.
This commit is contained in:
Mark Story 2012-11-24 10:14:22 -08:00
commit 780b6f01b4
2 changed files with 17 additions and 0 deletions

View file

@ -2465,6 +2465,10 @@ class DboSource extends DataSource {
$not = 'NOT ';
}
if (empty($value)) {
continue;
}
if (empty($value[1])) {
if ($not) {
$out[] = $not . '(' . $value[0] . ')';

View file

@ -159,6 +159,19 @@ class DboSourceTest extends CakeTestCase {
$this->assertEquals(' WHERE 1 = 1', $result);
}
/**
* test that booleans work on empty set.
*
* @return void
*/
public function testBooleanEmptyConditionsParsing() {
$result = $this->testDb->conditions(array('OR' => array()));
$this->assertEquals(' WHERE 1 = 1', $result, 'empty conditions failed');
$result = $this->testDb->conditions(array('OR' => array('OR' => array())));
$this->assertEquals(' WHERE 1 = 1', $result, 'nested empty conditions failed');
}
/**
* test that order() will accept objects made from DboSource::expression
*