Fixing substring quoting in DboSource::__quoteFields()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5274 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-06-12 15:13:53 +00:00
parent 335a384613
commit 3dbf59ece3
2 changed files with 5 additions and 2 deletions

View file

@ -1625,10 +1625,9 @@ class DboSource extends DataSource {
for($i = 0; $i < $pregCount; $i++) {
if(!empty($replace['1'][$i]) && !is_numeric($replace['1'][$i])) {
$conditions = preg_replace('/\b' . $replace['0'][$i] . '\b/', $this->name($replace['1'][$i]), $conditions);
$conditions = preg_replace('/\b' . preg_quote($replace['1'][$i]) . '\b/', $this->name($replace['1'][$i]), $conditions);
}
}
$conditions = rtrim($conditions);
return $conditions;
}
return false;

View file

@ -1314,6 +1314,10 @@ class DboSourceTest extends UnitTestCase {
}
function testStringConditionsParsing() {
$result = $this->db->conditions("ProjectBid.project_id = Project.id");
$expected = " WHERE `ProjectBid`.`project_id` = `Project`.`id`";
$this->assertEqual($result, $expected);
$result = $this->db->conditions("Candy.name LIKE 'a' AND HardCandy.name LIKE 'c'");
$expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'";
$this->assertEqual($result, $expected);