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-01-18 15:34:14 +01:00
parent 9ff5de80d4
commit d0c0426b1d

View File

@ -128,7 +128,7 @@ class GridFieldOrderableRows extends RequestHandler implements
$state->GridFieldOrderableRows->enabled = !$sorted;
if(!$sorted) {
return $list->sort($this->getSortField());
return $list->sort($this->getSortTable($list).'.'.$this->getSortField());
} else {
return $list;
}
@ -150,7 +150,7 @@ class GridFieldOrderableRows extends RequestHandler implements
$this->httpError(400);
}
$items = $list->byIDs($ids)->sort($field);
$items = $list->byIDs($ids)->sort($this->getSortTable($list).'.'.$field);
// Ensure that each provided ID corresponded to an actual object.
if(count($items) != count($ids)) {