diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-03-23 15:25:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-23 15:25:27 -0600 |
commit | b59f6dcca4f50de1091ff169135e025ba7f0b49e (patch) | |
tree | e9d95109512384c40d124c590eee95e0fcf6b904 /lib | |
parent | d2654c8aea3fbfa69169043674894448b23d8be6 (diff) | |
parent | 2d02a4735cff125229b071981ae14e42658b9fd6 (diff) | |
download | nextcloud-server-b59f6dcca4f50de1091ff169135e025ba7f0b49e.tar.gz nextcloud-server-b59f6dcca4f50de1091ff169135e025ba7f0b49e.zip |
Merge pull request #3850 from nextcloud/search-order
Fix search ordering
Diffstat (limited to 'lib')
-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 9c3b786ae87..9b2cff62627 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -667,6 +667,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()); + } + } } |