mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Correcting DboSource::order() identifier quoting, correcting bad DboSource tests, fixes #5900
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7942 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ac87db981a
commit
a5b7276696
2 changed files with 12 additions and 11 deletions
|
@ -2004,17 +2004,12 @@ class DboSource extends DataSource {
|
|||
}
|
||||
|
||||
if (is_array($keys)) {
|
||||
foreach ($keys as $key => $val) {
|
||||
if (is_numeric($key) && empty($val)) {
|
||||
unset($keys[$key]);
|
||||
}
|
||||
}
|
||||
$keys = array_filter($keys);
|
||||
}
|
||||
|
||||
if (empty($keys) || (is_array($keys) && count($keys) && isset($keys[0]) && empty($keys[0]))) {
|
||||
return '';
|
||||
}
|
||||
$flag = (isset($keys[0]) && $keys[0] == '(Model.field > 100) DESC');
|
||||
|
||||
if (is_array($keys)) {
|
||||
$keys = (Set::countDim($keys) > 1) ? array_map(array(&$this, 'order'), $keys) : $keys;
|
||||
|
@ -2034,9 +2029,11 @@ class DboSource extends DataSource {
|
|||
} else {
|
||||
$dir = '';
|
||||
}
|
||||
Configure::write('flag', $flag);
|
||||
$key = trim($this->name(trim($key)) . ' ' . trim($dir));
|
||||
Configure::write('flag', false);
|
||||
$key = trim($key);
|
||||
if (!preg_match('/\s/', $key)) {
|
||||
$key = $this->name($key);
|
||||
}
|
||||
$key .= ' ' . trim($dir);
|
||||
}
|
||||
$order[] = $this->order($key . $value);
|
||||
}
|
||||
|
|
|
@ -3196,10 +3196,10 @@ class DboSourceTest extends CakeTestCase {
|
|||
$this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC\s*$/', $result);
|
||||
|
||||
$result = $this->testDb->order("Dealer.id = 7 desc, Dealer.id = 3 desc, Dealer.title asc");
|
||||
$expected = " ORDER BY Dealer`.`id` = 7 desc, Dealer`.`id` = 3 desc, `Dealer`.`title` asc";
|
||||
$expected = " ORDER BY `Dealer`.`id` = 7 desc, `Dealer`.`id` = 3 desc, `Dealer`.`title` asc";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->order(array("Page.name"=>"='test' DESC"));
|
||||
$result = $this->testDb->order(array("Page.name" => "='test' DESC"));
|
||||
$this->assertPattern("/^\s*ORDER BY\s+`Page`\.`name`\s*='test'\s+DESC\s*$/", $result);
|
||||
|
||||
$result = $this->testDb->order("Page.name = 'view' DESC");
|
||||
|
@ -3227,6 +3227,10 @@ class DboSourceTest extends CakeTestCase {
|
|||
$result = $this->testDb->order("3963.191 * id");
|
||||
$expected = ' ORDER BY 3963.191 * id ASC';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->testDb->order(array('Property.sale_price IS NULL'));
|
||||
$expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testComplexSortExpression method
|
||||
|
|
Loading…
Add table
Reference in a new issue