"Fixes #4349, Correct usage of \"AND\" and \"and\" for conditions"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6641 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2008-04-09 02:24:09 +00:00
parent 1250c6e0cc
commit 85f2946c36
2 changed files with 13 additions and 1 deletions

View file

@ -1698,7 +1698,9 @@ class DboSource extends DataSource {
} else {
if (!empty($match['2']) && $quoteValues) {
$match['2'] = $this->value($match['2']);
$match['2'] = str_replace(' AND ', "' AND '", $match['2']);
if (preg_match('/^(?:' . join('\\x20)|(?:', $this->__sqlOps) . '\\x20)/i', $match['1'])) {
$match['2'] = str_replace(' AND ', "' AND '", $match['2']);
}
}
$data = $this->__quoteFields($key);
if ($data === $key) {

View file

@ -1467,6 +1467,16 @@ class DboSourceTest extends CakeTestCase {
$result = $this->db->conditions($conditions);
$expected = " WHERE `Company`.`name` like 'd.a%'";
$this->assertEqual($result, $expected);
$conditions = array('Artist.name' => 'JUDY and MARY');
$result = $this->db->conditions($conditions);
$expected = " WHERE `Artist`.`name` = 'JUDY and MARY'";
$this->assertEqual($result, $expected);
$conditions = array('Artist.name' => 'JUDY AND MARY');
$result = $this->db->conditions($conditions);
$expected = " WHERE `Artist`.`name` = 'JUDY AND MARY'";
$this->assertEqual($result, $expected);
}
function testQuotesInStringConditions() {