diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index b610ee121..abc75372d 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -2439,7 +2439,7 @@ class DboSource extends DataSource { } 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, '.')) { $key = $this->name($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 924e7256d..dfc432c91 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -3512,6 +3512,10 @@ class DboSourceTest extends CakeTestCase { $result = $this->testDb->order(array('Property.sale_price IS NULL')); $expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC'; $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()'); } /**