Skip to content

Commit

Permalink
FIX allow custom SELECT to be used for sorting in DataQuery::column().
Browse files Browse the repository at this point in the history
If a custom select clause (using special features such as `CASE`) is used, and it was added using `SQLSelect::selectField`, the custom select clause should be retained when calling DataQuery::column().
  • Loading branch information
GuySartorelli authored Dec 10, 2021
1 parent 0160008 commit 081959e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ORM/DataQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,12 @@ protected function ensureSelectContainsOrderbyColumns($query, $originalSelect =
// format internally; then this check can be part of selectField()
$selects = $query->getSelect();
if (!isset($selects[$col]) && !in_array($qualCol, $selects)) {
$query->selectField($qualCol);
// Use the original select if possible.
if (array_key_exists($col, $originalSelect)) {
$query->selectField($originalSelect[$col], $col);
} else {
$query->selectField($qualCol);
}
}
} else {
$qualCol = '"' . implode('"."', $parts) . '"';
Expand Down

0 comments on commit 081959e

Please sign in to comment.