BUGFIX Fixing SortColumn alias to be recognised by MSSQL/PGSQL

This commit is contained in:
Sean Harvey 2012-05-03 12:02:21 +12:00
parent 521d436b45
commit 37369abf1d
2 changed files with 9 additions and 9 deletions

View File

@ -240,16 +240,16 @@ class DataQuery {
// don't touch functions in the ORDER BY or function calls
// selected as fields
if(strpos($k, '(') !== false) continue;
// Pull through SortColumn references from the originalSelect variables
if(preg_match('/_SortColumn/', $k)) {
if(isset($originalSelect[$k])) $query->selectField($originalSelect[$k], $k);
continue;
}
$col = str_replace('"', '', trim($k));
$parts = explode('.', $col);
// Pull through SortColumn references from the originalSelect variables
if(preg_match('/_SortColumn/', $col)) {
if(isset($originalSelect[$col])) $query->selectField($originalSelect[$col], $col);
continue;
}
if(count($parts) == 1) {
$databaseFields = DataObject::database_fields($baseClass);

View File

@ -383,9 +383,9 @@ class SQLQuery {
$clause = trim($clause);
$column = "_SortColumn{$i}";
$this->selectField($clause, $column);
$this->orderby($column, $dir, false);
$this->orderby('"' . $column . '"', $dir, false);
$i++;
}
}