GridFieldOrderableRows: Prefix sort field with table name when sorting

Prevents ambiguities when the GridField's underlying DataList uses a query
that joins multiple tables having a sort field.
This commit is contained in:
Pieter Hollants 2015-02-23 14:29:08 +01:00
parent 4855ac5ec0
commit ea637b0ad5

View File

@ -190,7 +190,7 @@ class GridFieldOrderableRows extends RequestHandler implements
$sortterm = $this->extraSortFields.', '; $sortterm = $this->extraSortFields.', ';
} }
} }
$sortterm .= $this->getSortField(); $sortterm .= $this->getSortTable($list).'.'.$this->getSortField();
return $list->sort($sortterm); return $list->sort($sortterm);
} else { } else {
return $list; return $list;
@ -226,7 +226,7 @@ class GridFieldOrderableRows extends RequestHandler implements
$sortterm = $this->extraSortFields.', '; $sortterm = $this->extraSortFields.', ';
} }
} }
$sortterm .= $field; $sortterm .= $this->getSortTable($list).'.'.$field;
$items = $list->filter('ID', $ids)->sort($sortterm); $items = $list->filter('ID', $ids)->sort($sortterm);
// Ensure that each provided ID corresponded to an actual object. // Ensure that each provided ID corresponded to an actual object.