mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 23:49:55 +00:00
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:
commit
780b6f01b4
2 changed files with 17 additions and 0 deletions
|
@ -2465,6 +2465,10 @@ class DboSource extends DataSource {
|
||||||
$not = 'NOT ';
|
$not = 'NOT ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($value[1])) {
|
if (empty($value[1])) {
|
||||||
if ($not) {
|
if ($not) {
|
||||||
$out[] = $not . '(' . $value[0] . ')';
|
$out[] = $not . '(' . $value[0] . ')';
|
||||||
|
|
|
@ -159,6 +159,19 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->assertEquals(' WHERE 1 = 1', $result);
|
$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
|
* test that order() will accept objects made from DboSource::expression
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue