mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Fixing SortColumn alias to be recognised by MSSQL/PGSQL
This commit is contained in:
parent
521d436b45
commit
37369abf1d
@ -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);
|
||||
|
||||
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user