mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Removing DB coupling in SQLQuery::orderby() stopping functions from being fixed in the select list when used in orderby
BUGFIX DataQuery::ensureSelectContainsOrderbyColumns() shouldn't mess with "_SortColumn*" fields created by SQLQuery::orderby()
This commit is contained in:
parent
2f4b630340
commit
dd48a605b6
4
model/DataQuery.php
Normal file → Executable file
4
model/DataQuery.php
Normal file → Executable file
@ -176,8 +176,8 @@ class DataQuery {
|
||||
foreach($orderByFields as $ob => $col) {
|
||||
$col = trim($col);
|
||||
|
||||
// don't touch functions in the ORDER BY
|
||||
if(strpos($col, '(') !== false) continue;
|
||||
// don't touch functions in the ORDER BY or function calls selected as fields
|
||||
if(strpos($col, '(') !== false || preg_match('/_SortColumn/', $col)) continue;
|
||||
|
||||
$columnParts = explode(' ', $col);
|
||||
if (count($columnParts) == 2) {
|
||||
|
2
model/SQLQuery.php
Normal file → Executable file
2
model/SQLQuery.php
Normal file → Executable file
@ -300,7 +300,7 @@ class SQLQuery {
|
||||
|
||||
// If sort contains a function call, let's move the sort clause into a separate selected field.
|
||||
// Some versions of MySQL choke if you have a group function referenced directly in the ORDER BY
|
||||
if($combinedOrderby && strpos($combinedOrderby,'(') !== false && strtoupper(trim($combinedOrderby)) != DB::getConn()->random()) {
|
||||
if($combinedOrderby && strpos($combinedOrderby,'(') !== false) {
|
||||
// Sort can be "Col1 DESC|ASC, Col2 DESC|ASC", we need to handle that
|
||||
$sortParts = explode(",", $combinedOrderby);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user