Skip to content
This repository
Browse code

Modifying quoting method used in conditions with array values in DboS…

…ource, fixes #6519

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8243 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit a75d1fad2add184eb422142629bee24d66d4f9ab 1 parent caeac73
Nate Abele authored July 22, 2009
4  cake/libs/model/datasources/dbo_source.php
@@ -1842,9 +1842,9 @@ function conditionKeysToString($conditions, $quoteValues = true, $model = null)
1842 1842
 					if (array_keys($value) === array_values(array_keys($value))) {
1843 1843
 						$count = count($value);
1844 1844
 						if ($count === 1) {
1845  
-							$data = $this->name($key) . ' = (';
  1845
+							$data = $this->__quoteFields($key) . ' = (';
1846 1846
 						} else {
1847  
-							$data = $this->name($key) . ' IN (';
  1847
+							$data = $this->__quoteFields($key) . ' IN (';
1848 1848
 						}
1849 1849
 						if ($quoteValues || strpos($value[0], '-!') !== 0) {
1850 1850
 							if (is_object($model)) {
18  cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -2133,7 +2133,7 @@ function testStringConditionsParsing() {
2133 2133
 		$this->assertEqual($result, $expected);
2134 2134
 
2135 2135
 		$result = $this->testDb->conditions(array('score' => array(2=>1, 2, 10)));
2136  
-		$expected = " WHERE `score` IN (1, 2, 10)";
  2136
+		$expected = " WHERE score IN (1, 2, 10)";
2137 2137
 		$this->assertEqual($result, $expected);
2138 2138
 
2139 2139
 		$result = $this->testDb->conditions("Aro.rght = Aro.lft + 1.1");
@@ -2385,7 +2385,7 @@ function testArrayConditionsParsing() {
2385 2385
 		$this->assertEqual($result, $expected);
2386 2386
 
2387 2387
 		$result = $this->testDb->conditions(array('score' => array(1, 2, 10)));
2388  
-		$expected = " WHERE `score` IN (1, 2, 10)";
  2388
+		$expected = " WHERE score IN (1, 2, 10)";
2389 2389
 		$this->assertEqual($result, $expected);
2390 2390
 
2391 2391
 		$result = $this->testDb->conditions(array('score' => array()));
@@ -2476,7 +2476,7 @@ function testArrayConditionsParsing() {
2476 2476
 			'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912,999)),
2477 2477
 			'Enrollment.yearcompleted >' => '0')
2478 2478
 		);
2479  
-		$this->assertPattern('/^\s*WHERE\s+\(NOT\s+\(`Course`\.`id` IS NULL\)\s+AND NOT\s+\(`Course`\.`vet`\s+=\s+\'N\'\)\s+AND NOT\s+\(`level_of_education_id` IN \(912, 999\)\)\)\s+AND\s+`Enrollment`\.`yearcompleted`\s+>\s+\'0\'\s*$/', $result);
  2479
+		$this->assertPattern('/^\s*WHERE\s+\(NOT\s+\(`Course`\.`id` IS NULL\)\s+AND NOT\s+\(`Course`\.`vet`\s+=\s+\'N\'\)\s+AND NOT\s+\(level_of_education_id IN \(912, 999\)\)\)\s+AND\s+`Enrollment`\.`yearcompleted`\s+>\s+\'0\'\s*$/', $result);
2480 2480
 
2481 2481
 		$result = $this->testDb->conditions(array('id <>' => '8'));
2482 2482
 		$this->assertPattern('/^\s*WHERE\s+`id`\s+<>\s+\'8\'\s*$/', $result);
@@ -2495,16 +2495,24 @@ function testArrayConditionsParsing() {
2495 2495
 			"Listing.description LIKE" => "%term_2%"
2496 2496
 		);
2497 2497
 		$result = $this->testDb->conditions($conditions);
2498  
-		$expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))";
  2498
+		$expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND" .
  2499
+		" ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND" .
  2500
+		" ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))";
2499 2501
 		$this->assertEqual($result, $expected);
2500 2502
 
2501 2503
 		$result = $this->testDb->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah'));
2502 2504
 		$expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) = 'blah'";
2503 2505
 		$this->assertEqual($result, $expected);
2504 2506
 
  2507
+		$result = $this->testDb->conditions(array(
  2508
+			'MD5(CONCAT(Reg.email,Reg.id))' => array('blah', 'blahblah')
  2509
+		));
  2510
+		$expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) IN ('blah', 'blahblah')";
  2511
+		$this->assertEqual($result, $expected);
  2512
+
2505 2513
 		$conditions = array('id' => array(2, 5, 6, 9, 12, 45, 78, 43, 76));
2506 2514
 		$result = $this->testDb->conditions($conditions);
2507  
-		$expected = " WHERE `id` IN (2, 5, 6, 9, 12, 45, 78, 43, 76)";
  2515
+		$expected = " WHERE id IN (2, 5, 6, 9, 12, 45, 78, 43, 76)";
2508 2516
 		$this->assertEqual($result, $expected);
2509 2517
 
2510 2518
 		$conditions = array('title' => 'user(s)');

0 notes on commit a75d1fa

Please sign in to comment.
Something went wrong with that request. Please try again.