From d0c8cde9ab3312758642a5bdd53511ac2e2f73ea Mon Sep 17 00:00:00 2001 From: phpnut Date: Sat, 7 Apr 2007 06:29:46 +0000 Subject: [PATCH] Adding fixes for test in [4811] fixes Ticket #1100 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4812 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/datasources/dbo_source.php | 2 +- .../cases/libs/model/datasources/dbo_source.test.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 49b406c7b..7eeacaa15 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1529,7 +1529,7 @@ class DboSource extends DataSource { $end = preg_quote($this->endQuote); } $conditions = str_replace(array($start, $end), '', $conditions); - preg_match_all('/(?:\'[^\'\\\]*(?:\\\.[^\'\\\]*)*\')|([a-z0-9_' . $start . $end . ']*\\.[a-z0-9_' . $start . $end . ']*)/i', $conditions, $replace, PREG_PATTERN_ORDER); + preg_match_all('/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_' . $start . $end . ']*\\.[a-z0-9_' . $start . $end . ']*)/i', $conditions, $replace, PREG_PATTERN_ORDER); if(isset($replace['1']['0'])) { $pregCount = count($replace['1']); 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 4f1b2c579..189f7d9c0 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -1000,21 +1000,21 @@ class DboSourceTest extends UnitTestCase { $expected = " WHERE DATEDIFF(NOW(),`Article`.`published`) < 1 && `Article`.`live`=1"; $this->assertEqual($result, $expected); } - + function testQuotesInStringConditions() { $result = $this->db->conditions('Member.email = \'mariano@cricava.com\''); $expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\''; $this->assertEqual($result, $expected); - + $result = $this->db->conditions('Member.email = "mariano@cricava.com"'); $expected = ' WHERE `Member`.`email` = "mariano@cricava.com"'; $this->assertEqual($result, $expected); - + $result = $this->db->conditions('Member.email = \'mariano@cricava.com\' AND Member.user LIKE \'mariano.iglesias%\''); $expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\' AND `Member`.`user` LIKE \'mariano.iglesias%\''; $this->assertEqual($result, $expected); - + $result = $this->db->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"'); $expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"'; $this->assertEqual($result, $expected);