mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Fixing NOT operations in query conditions in DboSource (Ticket #2307)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4704 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f32cc3eb79
commit
0c2b92a650
2 changed files with 12 additions and 0 deletions
|
@ -1424,6 +1424,9 @@ class DboSource extends DataSource {
|
|||
$join = ' ' . strtoupper($key) . ' ';
|
||||
$value = $this->conditionKeysToString($value, $quoteValues);
|
||||
if (strpos($join, 'NOT') !== false) {
|
||||
if (up(trim($key)) == 'NOT') {
|
||||
$key = 'AND ' . $key;
|
||||
}
|
||||
$out[] = 'NOT (' . join(') ' . strtoupper($key) . ' (', $value) . ')';
|
||||
} else {
|
||||
$out[] = '(' . join(') ' . strtoupper($key) . ' (', $value) . ')';
|
||||
|
|
|
@ -943,6 +943,15 @@ class DboSourceTest extends UnitTestCase {
|
|||
|
||||
$result = $this->db->conditions(array('(Usergroup.permissions) & 4' => 4));
|
||||
$this->assertPattern('/^\s*WHERE\s+\(`Usergroup`\.`permissions`\)\s+& 4\s+=\s+4\s*$/', $result);
|
||||
|
||||
//$result = $this->db->conditions(array('((Usergroup.permissions) & 4)' => 4));
|
||||
//$this->assertPattern('/^\s*WHERE\s+\(\(`Usergroup`\.`permissions`\)\s+& 4\)\s+=\s+4\s*$/', $result);
|
||||
|
||||
$result = $this->db->conditions(array(
|
||||
'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912,999)),
|
||||
'Enrollment.yearcompleted' => '> 0')
|
||||
);
|
||||
$this->assertPattern('/^\s*WHERE\s+NOT\s+\(`Course`\.`id` IS NULL\)\s+AND NOT\s+\(`Course`\.`vet`\s+=\s+\'N\'\)\s+AND NOT\s+\(`level_of_education_id` IN \(912, 999\)\s*\)\s+AND\s+`Enrollment`\.`yearcompleted`\s+>\s+0\s*$/', $result);
|
||||
}
|
||||
|
||||
function testFieldParsing() {
|
||||
|
|
Loading…
Add table
Reference in a new issue