Fix search ordering
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
8217b16cfe
commit
2d02a4735c
2
3rdparty
2
3rdparty
|
@ -1 +1 @@
|
|||
Subproject commit 48420b6fd7012d23550e2c43541b4b4ad0a85aa5
|
||||
Subproject commit a82f327d1ded4b8a24e99dea721f82e1f69153f5
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue