]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix search ordering 3850/head
authorRobin Appelman <robin@icewind.nl>
Wed, 15 Mar 2017 13:46:23 +0000 (14:46 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 23 Mar 2017 21:24:50 +0000 (15:24 -0600)
Signed-off-by: Robin Appelman <robin@icewind.nl>
3rdparty
lib/private/Files/Cache/Cache.php
lib/private/Files/Cache/QuerySearchHelper.php

index 48420b6fd7012d23550e2c43541b4b4ad0a85aa5..a82f327d1ded4b8a24e99dea721f82e1f69153f5 160000 (submodule)
--- a/3rdparty
+++ b/3rdparty
@@ -1 +1 @@
-Subproject commit 48420b6fd7012d23550e2c43541b4b4ad0a85aa5
+Subproject commit a82f327d1ded4b8a24e99dea721f82e1f69153f5
index 95a78f998291a4f9ec9cb12343aeb7606b61bc9f..b14f80a7e2368152001985449c615770a4916c49 100644 (file)
@@ -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());
                }
index 7d8098f0efa5f016b9e113b2a5fa6bea4b34e68d..2d20da72f51a02e71593c8ed00d4d400b40428e9 100644 (file)
@@ -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());
+               }
+       }
 }