BUGFIX DataList used in SearchContext::getQuery() should be returned so limit() and sort() are applied correctly

This commit is contained in:
Sean Harvey 2012-06-15 16:20:45 +12:00
parent b04c199064
commit 8b834877f9

View File

@ -119,15 +119,17 @@ class SearchContext extends Object {
if(!($existingQuery instanceof DataList)) throw new InvalidArgumentException("existingQuery must be DataList");
if($existingQuery->dataClass() != $this->modelClass) throw new InvalidArgumentException("existingQuery's dataClass is " . $existingQuery->dataClass() . ", $this->modelClass expected.");
$query = $existingQuery;
} else {
$query = DataList::create($this->modelClass);
}
if(is_array($limit)) $query->limit(isset($limit['limit']) ? $limit['limit'] : null, isset($limit['start']) ? $limit['start'] : null);
else $query->limit($limit);
if(is_array($limit)) {
$query = $query->limit(isset($limit['limit']) ? $limit['limit'] : null, isset($limit['start']) ? $limit['start'] : null);
} else {
$query = $query->limit($limit);
}
$query->sort($sort);
$query = $query->sort($sort);
// hack to work with $searchParems when it's an Object
$searchParamArray = array();