Drive query ordering and paging more cohesively
Summary: Ref T7803. Ordering and paging are inherently intertwined, but they often aren't driven by the same data right now. Start driving them through the same data: - `getOrderableColumns()` defines orderable and pageable columns. - `getPagingValueMap()` reads values from a cursor. This is generally sufficient to implement both paging and ordering. Also, add some more sanity checks to try to curtail the number of ambiguous/invalid orderings applications produce, since these cause subtle/messy bugs. Test Plan: - Paged through pastes and a few other object types. - Intentionally changed defaults to be invalid and hit some of the errors. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7803 Differential Revision: https://secure.phabricator.com/D12355
This commit is contained in:
@@ -72,7 +72,7 @@ final class PhabricatorQueryOrderVector
|
||||
'Order vector "%s" specifies order "%s" twice. Each component '.
|
||||
'of an ordering must be unique.',
|
||||
implode(', ', $vector),
|
||||
$item));
|
||||
$item->getOrderKey()));
|
||||
}
|
||||
|
||||
$items[$item->getOrderKey()] = $item;
|
||||
@@ -84,6 +84,14 @@ final class PhabricatorQueryOrderVector
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function getAsString() {
|
||||
$scalars = array();
|
||||
foreach ($this->items as $item) {
|
||||
$scalars[] = $item->getAsScalar();
|
||||
}
|
||||
return implode(', ', $scalars);
|
||||
}
|
||||
|
||||
|
||||
/* -( Iterator Interface )------------------------------------------------- */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user