Permalink
Browse files

Fixing order condition quoting to allow fields with - in them. Fixes #…

  • Loading branch information...
1 parent 9213495 commit 8a883013197516a558e8096c342981f327491a54 @markstory markstory committed Mar 25, 2011
@@ -2108,7 +2108,7 @@ function order($keys, $direction = 'ASC') {
$keys = preg_replace('/ORDER\\x20BY/i', '', $keys);
if (strpos($keys, '.')) {
- preg_match_all('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', $keys, $result, PREG_PATTERN_ORDER);
+ preg_match_all('/([a-zA-Z0-9_-]{1,})\\.([a-zA-Z0-9_-]{1,})/', $keys, $result, PREG_PATTERN_ORDER);
$pregCount = count($result[0]);
for ($i = 0; $i < $pregCount; $i++) {
@@ -3325,6 +3325,10 @@ function testOrderParsing() {
$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() %s');
}
/**
* testComplexSortExpression method
@@ -3915,4 +3919,4 @@ function testReadOnlyCallingQueryAssociationWhenDefined() {
$this->assertTrue(is_array($result));
}
}
-?>
+?>

0 comments on commit 8a88301

Please sign in to comment.