]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add a method to compare empty strings with an expression 5966/head
authorJoas Schilling <coding@schilljs.com>
Tue, 25 Jul 2017 13:34:59 +0000 (15:34 +0200)
committerJoas Schilling <coding@schilljs.com>
Thu, 3 Aug 2017 14:41:03 +0000 (16:41 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
lib/private/Repair/NC13/RepairInvalidPaths.php
lib/public/DB/QueryBuilder/IExpressionBuilder.php

index f172260df79e8d6b1516efb8bb39b8ec9ecbfd8b..a32ae4a1827d056096b3e383430fc83c01946575 100644 (file)
@@ -31,6 +31,7 @@ use OC\DB\QueryBuilder\QueryFunction;
 use OC\DB\QueryBuilder\QuoteHelper;
 use OCP\DB\QueryBuilder\IExpressionBuilder;
 use OCP\DB\QueryBuilder\ILiteral;
+use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\DB\QueryBuilder\IQueryFunction;
 use OCP\IDBConnection;
 
@@ -350,6 +351,28 @@ class ExpressionBuilder implements IExpressionBuilder {
                return $this->expressionBuilder->notIn($x, $y);
        }
 
+       /**
+        * Creates a $x = '' statement, because Oracle needs a different check
+        *
+        * @param string $x The field in string format to be inspected by the comparison.
+        * @return string
+        * @since 13.0.0
+        */
+       public function emptyString($x) {
+               return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR));
+       }
+
+       /**
+        * Creates a `$x <> ''` statement, because Oracle needs a different check
+        *
+        * @param string $x The field in string format to be inspected by the comparison.
+        * @return string
+        * @since 13.0.0
+        */
+       public function nonEmptyString($x) {
+               return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR));
+       }
+
        /**
         * Binary AND Operator copies a bit to the result if it exists in both operands.
         *
index dc5c8bccbca8918cd612218c2e77132fb18e7830..693d2faecffbebf8e910e7006bd0cb5808153173 100644 (file)
@@ -137,6 +137,28 @@ class OCIExpressionBuilder extends ExpressionBuilder {
                return $this->expressionBuilder->notIn($x, $y);
        }
 
+       /**
+        * Creates a $x = '' statement, because Oracle needs a different check
+        *
+        * @param string $x The field in string format to be inspected by the comparison.
+        * @return string
+        * @since 13.0.0
+        */
+       public function emptyString($x) {
+               return $this->isNull($x);
+       }
+
+       /**
+        * Creates a `$x <> ''` statement, because Oracle needs a different check
+        *
+        * @param string $x The field in string format to be inspected by the comparison.
+        * @return string
+        * @since 13.0.0
+        */
+       public function nonEmptyString($x) {
+               return $this->isNotNull($x);
+       }
+
        /**
         * Returns a IQueryFunction that casts the column to the given type
         *
index f19a4e41f39c61d43b7d220ff33806808a1a744d..57a528707b9e87cb01ade0cd4e9f2be5097ed4b8 100644 (file)
@@ -66,7 +66,7 @@ class RepairInvalidPaths implements IRepairStep {
                        ->from('filecache', 'f')
                        ->innerJoin('f', 'filecache', 'p', $builder->expr()->andX(
                                $builder->expr()->eq('f.parent', 'p.fileid'),
-                               $builder->expr()->isNotNull('p.name')
+                               $builder->expr()->nonEmptyString('p.name')
                        ))
                        ->where($builder->expr()->neq('f.path', $computedPath))
                        ->setMaxResults(self::MAX_ROWS);
index c123875b80312b324b7037fc104793c3d3715b57..eab93b52f8a279013bd18767121d1698d83261fa 100644 (file)
@@ -305,6 +305,24 @@ interface IExpressionBuilder {
         */
        public function notIn($x, $y, $type = null);
 
+       /**
+        * Creates a $x = '' statement, because Oracle needs a different check
+        *
+        * @param string $x The field in string format to be inspected by the comparison.
+        * @return string
+        * @since 13.0.0
+        */
+       public function emptyString($x);
+
+       /**
+        * Creates a `$x <> ''` statement, because Oracle needs a different check
+        *
+        * @param string $x The field in string format to be inspected by the comparison.
+        * @return string
+        * @since 13.0.0
+        */
+       public function nonEmptyString($x);
+
 
        /**
         * Creates a bitwise AND comparison