mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
"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:
parent
1250c6e0cc
commit
85f2946c36
2 changed files with 13 additions and 1 deletions
|
@ -1698,8 +1698,10 @@ class DboSource extends DataSource {
|
|||
} else {
|
||||
if (!empty($match['2']) && $quoteValues) {
|
||||
$match['2'] = $this->value($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) {
|
||||
$data = $this->name($key) . ' ' . $match['1'] . ' ' . $match['2'];
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue