Merge pull request #3850 from nextcloud/search-order
Fix search ordering
This commit is contained in:
commit
b59f6dcca4
3 changed files with 14 additions and 1 deletions
2
3rdparty
2
3rdparty
|
@ -1 +1 @@
|
||||||
Subproject commit 48420b6fd7012d23550e2c43541b4b4ad0a85aa5
|
Subproject commit a82f327d1ded4b8a24e99dea721f82e1f69153f5
|
|
@ -667,6 +667,8 @@ class Cache implements ICache {
|
||||||
|
|
||||||
$query->andWhere($this->querySearchHelper->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation()));
|
$query->andWhere($this->querySearchHelper->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation()));
|
||||||
|
|
||||||
|
$this->querySearchHelper->addSearchOrdersToQuery($query, $searchQuery->getOrder());
|
||||||
|
|
||||||
if ($searchQuery->getLimit()) {
|
if ($searchQuery->getLimit()) {
|
||||||
$query->setMaxResults($searchQuery->getLimit());
|
$query->setMaxResults($searchQuery->getLimit());
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ use OCP\Files\IMimeTypeLoader;
|
||||||
use OCP\Files\Search\ISearchBinaryOperator;
|
use OCP\Files\Search\ISearchBinaryOperator;
|
||||||
use OCP\Files\Search\ISearchComparison;
|
use OCP\Files\Search\ISearchComparison;
|
||||||
use OCP\Files\Search\ISearchOperator;
|
use OCP\Files\Search\ISearchOperator;
|
||||||
|
use OCP\Files\Search\ISearchOrder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tools for transforming search queries into database queries
|
* Tools for transforming search queries into database queries
|
||||||
|
@ -185,4 +186,14 @@ class QuerySearchHelper {
|
||||||
}
|
}
|
||||||
return $builder->createNamedParameter($value, $type);
|
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 a new issue