diff options
author | Joas Schilling <coding@schilljs.com> | 2017-07-25 15:34:59 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-08-02 09:50:41 +0200 |
commit | 78412fda9c0af263ecd6454fd52d72a040debe2f (patch) | |
tree | 11dd18fef33868ef0b43ca4a35833979c481e24c /lib/private/DB | |
parent | 100fe07f5d54e5dfe8bcb369f1ee35dc1736f348 (diff) | |
download | nextcloud-server-78412fda9c0af263ecd6454fd52d72a040debe2f.tar.gz nextcloud-server-78412fda9c0af263ecd6454fd52d72a040debe2f.zip |
Add a method to compare empty strings with an expression
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/DB')
-rw-r--r-- | lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php | 23 | ||||
-rw-r--r-- | lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php | 22 |
2 files changed, 45 insertions, 0 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 |