summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-03-15 14:46:23 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-03-23 15:24:50 -0600
commit2d02a4735cff125229b071981ae14e42658b9fd6 (patch)
tree839ae812e63abdca5da72c08e7100ec08f443094 /lib/private
parent8217b16cfecece7e5f5e6a76b0716ef155ae4b63 (diff)
downloadnextcloud-server-2d02a4735cff125229b071981ae14e42658b9fd6.tar.gz
nextcloud-server-2d02a4735cff125229b071981ae14e42658b9fd6.zip
Fix search ordering
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/Cache/Cache.php2
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php11
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());
+ }
+ }
}