Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUGFIX Fixing SortColumn alias to be recognised by MSSQL/PGSQL

  • Loading branch information...
commit 37369abf1d81e41a32dd128fc0a7b00b04308384 1 parent 521d436
@halkyon halkyon authored
Showing with 8 additions and 8 deletions.
  1. +6 −6 model/DataQuery.php
  2. +2 −2 model/SQLQuery.php
View
12 model/DataQuery.php
@@ -240,16 +240,16 @@ protected function ensureSelectContainsOrderbyColumns($query, $originalSelect =
// don't touch functions in the ORDER BY or function calls
// selected as fields
if(strpos($k, '(') !== false) continue;
-
+
+ $col = str_replace('"', '', trim($k));
+ $parts = explode('.', $col);
+
// Pull through SortColumn references from the originalSelect variables
- if(preg_match('/_SortColumn/', $k)) {
- if(isset($originalSelect[$k])) $query->selectField($originalSelect[$k], $k);
+ if(preg_match('/_SortColumn/', $col)) {
+ if(isset($originalSelect[$col])) $query->selectField($originalSelect[$col], $col);
continue;
}
- $col = str_replace('"', '', trim($k));
- $parts = explode('.', $col);
-
if(count($parts) == 1) {
$databaseFields = DataObject::database_fields($baseClass);
View
4 model/SQLQuery.php
@@ -383,9 +383,9 @@ public function orderby($clauses = null, $direction = null, $clear = true) {
$clause = trim($clause);
$column = "_SortColumn{$i}";
-
+
$this->selectField($clause, $column);
- $this->orderby($column, $dir, false);
+ $this->orderby('"' . $column . '"', $dir, false);
$i++;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.