diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 95a78f99829..b14f80a7e23 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -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()); } diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index 7d8098f0efa..2d20da72f51 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -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()); + } + } } |