Adding fix for <> condition in DboSource (Ticket #2101)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4865 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-04-17 05:17:06 +00:00
parent a152849bde
commit 5461eec22d
2 changed files with 8 additions and 1 deletions

View file

@ -1567,7 +1567,7 @@ class DboSource extends DataSource {
$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)) {
} elseif (preg_match('/^([a-z]*\\([a-z0-9]*\\)\\x20?|(?:' . join('\\x20)|(?:', $this->__sqlOps) . '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)?(.*)/i', $value, $match)) {
if (preg_match('/(\\x20[\\w]*\\x20)/', $key, $regs)) {
$clause = $regs['1'];
$key = preg_replace('/' . $regs['1'] . '/', '', $key);

View file

@ -1377,6 +1377,13 @@ class DboSourceTest extends UnitTestCase {
'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);
$result = $this->db->conditions(array('id' => '<> 8'));
$this->assertPattern('/^\s*WHERE\s+`id`\s+<>\s+8\s*$/', $result);
//$result = $this->db->conditions(array('TestModel.field' => '= gribe$@()lu'));
//$expected = " WHERE `TestModel.field` = 'gribe$@()lu'";
//$this->assertEqual($result, $expected);
}
function testFieldParsing() {