diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 62d5e5044..909a48d89 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -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) { diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 63901e1e0..81ab0f98d 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -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() {