Merge pull request #6216 from jonom/fix-version-sql

FIX Versioned sort by ID
This commit is contained in:
Damian Mooyman 2016-11-17 15:47:44 +13:00 committed by GitHub
commit c2287c14ff

View File

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