summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-07-25 15:34:59 +0200
committerJoas Schilling <coding@schilljs.com>2017-08-03 16:41:03 +0200
commit3a111adc33c20e418fa7ffda9de8a8ef99bd3c4b (patch)
tree8777c28254beeaff47f42e45993a3a6cd016397e
parent4f31860fd65c5dbe2161625be0a085d7417a6b24 (diff)
downloadnextcloud-server-3a111adc33c20e418fa7ffda9de8a8ef99bd3c4b.tar.gz
nextcloud-server-3a111adc33c20e418fa7ffda9de8a8ef99bd3c4b.zip
Add a method to compare empty strings with an expression
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php23
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php22
-rw-r--r--lib/private/Repair/NC13/RepairInvalidPaths.php2
-rw-r--r--lib/public/DB/QueryBuilder/IExpressionBuilder.php18
4 files changed, 64 insertions, 1 deletions
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
index f172260df79..a32ae4a1827 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
@@ -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;
@@ -351,6 +352,28 @@ class ExpressionBuilder implements IExpressionBuilder {
}
/**
+ * 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.
*
* @param string|ILiteral $x The field or value to check
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
index dc5c8bccbca..693d2faecff 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
@@ -138,6 +138,28 @@ class OCIExpressionBuilder extends ExpressionBuilder {
}
/**
+ * 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
*
* @param string $column
diff --git a/lib/private/Repair/NC13/RepairInvalidPaths.php b/lib/private/Repair/NC13/RepairInvalidPaths.php
index f19a4e41f39..57a528707b9 100644
--- a/lib/private/Repair/NC13/RepairInvalidPaths.php
+++ b/lib/private/Repair/NC13/RepairInvalidPaths.php
@@ -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);
diff --git a/lib/public/DB/QueryBuilder/IExpressionBuilder.php b/lib/public/DB/QueryBuilder/IExpressionBuilder.php
index c123875b803..eab93b52f8a 100644
--- a/lib/public/DB/QueryBuilder/IExpressionBuilder.php
+++ b/lib/public/DB/QueryBuilder/IExpressionBuilder.php
@@ -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