Fix search ordering

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2017-03-15 14:46:23 +01:00 committed by Morris Jobke
parent 8217b16cfe
commit 2d02a4735c
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
3 changed files with 14 additions and 1 deletions

@ -1 +1 @@
Subproject commit 48420b6fd7012d23550e2c43541b4b4ad0a85aa5
Subproject commit a82f327d1ded4b8a24e99dea721f82e1f69153f5

View File

@ -666,6 +666,8 @@ class Cache implements ICache {
$query->andWhere($this->querySearchHelper->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation()));
$this->querySearchHelper->addSearchOrdersToQuery($query, $searchQuery->getOrder());
if ($searchQuery->getLimit()) {
$query->setMaxResults($searchQuery->getLimit());
}

View File

@ -26,6 +26,7 @@ use OCP\Files\IMimeTypeLoader;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
use OCP\Files\Search\ISearchOperator;
use OCP\Files\Search\ISearchOrder;
/**
* Tools for transforming search queries into database queries
@ -185,4 +186,14 @@ class QuerySearchHelper {
}
return $builder->createNamedParameter($value, $type);
}
/**
* @param IQueryBuilder $query
* @param ISearchOrder[] $orders
*/
public function addSearchOrdersToQuery(IQueryBuilder $query, array $orders) {
foreach ($orders as $order) {
$query->addOrderBy($order->getField(), $order->getDirection());
}
}
}