closes #4935, NOT usage requires ()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7215 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-06-19 16:12:57 +00:00
parent dd909280e5
commit 7d06612b35
2 changed files with 7 additions and 3 deletions

View file

@ -1760,7 +1760,6 @@ class DboSource extends DataSource {
}
$value = $this->conditionKeysToString($value, $quoteValues, $model);
if (strpos($join, 'NOT') !== false) {
if (strtoupper(trim($key)) == 'NOT') {
$key = 'AND ' . trim($key);
@ -1770,10 +1769,15 @@ class DboSource extends DataSource {
$not = null;
}
if (empty($value[1])) {
$out[] = $not . $value[0];
if ($not) {
$out[] = $not . '(' . $value[0] . ')';
} else {
$out[] = $not . $value[0] ;
}
} else {
$out[] = '(' . $not . '(' . join(') ' . strtoupper($key) . ' (', $value) . '))';
}
} else {
if (is_object($value) && isset($value->type)) {
if ($value->type == 'identifier') {

View file

@ -2460,7 +2460,7 @@ class DboSourceTest extends CakeTestCase {
"Listing.description LIKE" => "%term_2%"
);
$result = $this->testDb->conditions($conditions);
$expected = " WHERE NOT `Listing`.`expiration` BETWEEN '1' AND '100' AND ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))";
$expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))";
$this->assertEqual($result, $expected);
$result = $this->testDb->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah'));