FIX Versioned sort by ID

Prevent SQL error from a Versioned DataObject with e.g. $default_sort = 'ID DESC'
This commit is contained in:
Jonathon Menz 2016-10-21 19:33:32 -07:00
parent 8a0383e5a9
commit bec5adf09b

View File

@ -313,7 +313,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
// Ensure that any sort order referring to this ID is correctly aliased
$orders = $query->getOrderBy();
foreach($orders as $order => $dir) {
if($order === "\"$baseTable\".\"ID\"") {
if($order === "\"$baseTable\".\"ID\"" || trim($order, "'\"") === "ID") {
unset($orders[$order]);
$orders["\"{$baseTable}_versions\".\"RecordID\""] = $dir;
}