mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing order condition quoting to allow fields with - in them. Fixes #1599
This commit is contained in:
parent
b8e560b8b4
commit
532555b94b
2 changed files with 5 additions and 1 deletions
|
@ -2439,7 +2439,7 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($key, '.')) {
|
if (strpos($key, '.')) {
|
||||||
$key = preg_replace_callback('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', array(&$this, '__quoteMatchedField'), $key);
|
$key = preg_replace_callback('/([a-zA-Z0-9_-]{1,})\\.([a-zA-Z0-9_-]{1,})/', array(&$this, '__quoteMatchedField'), $key);
|
||||||
}
|
}
|
||||||
if (!preg_match('/\s/', $key) && !strpos($key, '.')) {
|
if (!preg_match('/\s/', $key) && !strpos($key, '.')) {
|
||||||
$key = $this->name($key);
|
$key = $this->name($key);
|
||||||
|
|
|
@ -3512,6 +3512,10 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$result = $this->testDb->order(array('Property.sale_price IS NULL'));
|
$result = $this->testDb->order(array('Property.sale_price IS NULL'));
|
||||||
$expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC';
|
$expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->testDb->order(array('Export.column-name' => 'ASC'));
|
||||||
|
$expected = ' ORDER BY `Export`.`column-name` ASC';
|
||||||
|
$this->assertEqual($result, $expected, 'Columns with -s are not working with order()');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue