summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-06-20 17:53:20 +0200
committerRobin Appelman <robin@icewind.nl>2022-08-16 12:07:09 +0200
commit9b52663a81ef4db0aa458ed6b34dfaab872e3243 (patch)
tree922780103997813d07b63f86c0964a7a75d66bb8 /lib/private
parentcb97e8f15c75cc46e345ebfc79dcad1b9c48bd01 (diff)
downloadnextcloud-server-9b52663a81ef4db0aa458ed6b34dfaab872e3243.tar.gz
nextcloud-server-9b52663a81ef4db0aa458ed6b34dfaab872e3243.zip
Revert "make expression build return IQueryFunction instead of string"
This reverts commit 813b50ed428a8bc36817d19c84444e96dbe3b668. Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php96
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php4
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php50
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php4
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php11
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php12
6 files changed, 85 insertions, 92 deletions
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
index 333984bde71..ae4f19f5d18 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
@@ -114,12 +114,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function comparison($x, string $operator, $y, $type = null): IQueryFunction {
+ public function comparison($x, string $operator, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->comparison($x, $operator, $y));
+ return $this->expressionBuilder->comparison($x, $operator, $y);
}
/**
@@ -137,12 +137,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function eq($x, $y, $type = null): IQueryFunction {
+ public function eq($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->eq($x, $y));
+ return $this->expressionBuilder->eq($x, $y);
}
/**
@@ -159,12 +159,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function neq($x, $y, $type = null): IQueryFunction {
+ public function neq($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->neq($x, $y));
+ return $this->expressionBuilder->neq($x, $y);
}
/**
@@ -181,12 +181,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function lt($x, $y, $type = null): IQueryFunction {
+ public function lt($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->lt($x, $y));
+ return $this->expressionBuilder->lt($x, $y);
}
/**
@@ -203,12 +203,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function lte($x, $y, $type = null): IQueryFunction {
+ public function lte($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->lte($x, $y));
+ return $this->expressionBuilder->lte($x, $y);
}
/**
@@ -225,12 +225,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function gt($x, $y, $type = null): IQueryFunction {
+ public function gt($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->gt($x, $y));
+ return $this->expressionBuilder->gt($x, $y);
}
/**
@@ -247,12 +247,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function gte($x, $y, $type = null): IQueryFunction {
+ public function gte($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->gte($x, $y));
+ return $this->expressionBuilder->gte($x, $y);
}
/**
@@ -260,11 +260,11 @@ class ExpressionBuilder implements IExpressionBuilder {
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL.
*
- * @return IQueryFunction
+ * @return string
*/
- public function isNull($x): IQueryFunction {
+ public function isNull($x): string {
$x = $this->helper->quoteColumnName($x);
- return new QueryFunction($this->expressionBuilder->isNull($x));
+ return $this->expressionBuilder->isNull($x);
}
/**
@@ -272,11 +272,11 @@ class ExpressionBuilder implements IExpressionBuilder {
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL.
*
- * @return IQueryFunction
+ * @return string
*/
- public function isNotNull($x): IQueryFunction {
+ public function isNotNull($x): string {
$x = $this->helper->quoteColumnName($x);
- return new QueryFunction($this->expressionBuilder->isNotNull($x));
+ return $this->expressionBuilder->isNotNull($x);
}
/**
@@ -287,12 +287,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function like($x, $y, $type = null): IQueryFunction {
+ public function like($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->like($x, $y));
+ return $this->expressionBuilder->like($x, $y);
}
/**
@@ -303,11 +303,11 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
* @since 9.0.0
*/
- public function iLike($x, $y, $type = null): IQueryFunction {
- return new QueryFunction($this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)));
+ public function iLike($x, $y, $type = null): string {
+ return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y));
}
/**
@@ -318,12 +318,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function notLike($x, $y, $type = null): IQueryFunction {
+ public function notLike($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->notLike($x, $y));
+ return $this->expressionBuilder->notLike($x, $y);
}
/**
@@ -334,12 +334,12 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function in($x, $y, $type = null): IQueryFunction {
+ public function in($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnNames($y);
- return new QueryFunction($this->expressionBuilder->in($x, $y));
+ return $this->expressionBuilder->in($x, $y);
}
/**
@@ -350,34 +350,34 @@ class ExpressionBuilder implements IExpressionBuilder {
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
- * @return IQueryFunction
+ * @return string
*/
- public function notIn($x, $y, $type = null): IQueryFunction {
+ public function notIn($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnNames($y);
- return new QueryFunction($this->expressionBuilder->notIn($x, $y));
+ return $this->expressionBuilder->notIn($x, $y);
}
/**
* Creates a $x = '' statement, because Oracle needs a different check
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
- * @return IQueryFunction
+ * @return string
* @since 13.0.0
*/
- public function emptyString($x): IQueryFunction {
- return new QueryFunction($this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR)));
+ public function emptyString($x): string {
+ return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR));
}
/**
* Creates a `$x <> ''` statement, because Oracle needs a different check
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
- * @return IQueryFunction
+ * @return string
* @since 13.0.0
*/
- public function nonEmptyString($x): IQueryFunction {
- return new QueryFunction($this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR)));
+ public function nonEmptyString($x): string {
+ return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR));
}
/**
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
index 74209d0c3da..3bb54d4b26e 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
@@ -49,10 +49,10 @@ class MySqlExpressionBuilder extends ExpressionBuilder {
/**
* @inheritdoc
*/
- public function iLike($x, $y, $type = null): IQueryFunction {
+ public function iLike($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->comparison($x, ' COLLATE ' . $this->collation . ' LIKE', $y));
+ return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->collation . ' LIKE', $y);
}
/**
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
index 20d68b30b33..f9b58d7d8ed 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
@@ -49,101 +49,101 @@ class OCIExpressionBuilder extends ExpressionBuilder {
/**
* @inheritdoc
*/
- public function comparison($x, string $operator, $y, $type = null): IQueryFunction {
+ public function comparison($x, string $operator, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->comparison($x, $operator, $y));
+ return $this->expressionBuilder->comparison($x, $operator, $y);
}
/**
* @inheritdoc
*/
- public function eq($x, $y, $type = null): IQueryFunction {
+ public function eq($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->eq($x, $y));
+ return $this->expressionBuilder->eq($x, $y);
}
/**
* @inheritdoc
*/
- public function neq($x, $y, $type = null): IQueryFunction {
+ public function neq($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->neq($x, $y));
+ return $this->expressionBuilder->neq($x, $y);
}
/**
* @inheritdoc
*/
- public function lt($x, $y, $type = null): IQueryFunction {
+ public function lt($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->lt($x, $y));
+ return $this->expressionBuilder->lt($x, $y);
}
/**
* @inheritdoc
*/
- public function lte($x, $y, $type = null): IQueryFunction {
+ public function lte($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->lte($x, $y));
+ return $this->expressionBuilder->lte($x, $y);
}
/**
* @inheritdoc
*/
- public function gt($x, $y, $type = null): IQueryFunction {
+ public function gt($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->gt($x, $y));
+ return $this->expressionBuilder->gt($x, $y);
}
/**
* @inheritdoc
*/
- public function gte($x, $y, $type = null): IQueryFunction {
+ public function gte($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->gte($x, $y));
+ return $this->expressionBuilder->gte($x, $y);
}
/**
* @inheritdoc
*/
- public function in($x, $y, $type = null): IQueryFunction {
+ public function in($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->in($x, $y));
+ return $this->expressionBuilder->in($x, $y);
}
/**
* @inheritdoc
*/
- public function notIn($x, $y, $type = null): IQueryFunction {
+ public function notIn($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);
- return new QueryFunction($this->expressionBuilder->notIn($x, $y));
+ return $this->expressionBuilder->notIn($x, $y);
}
/**
* Creates a $x = '' statement, because Oracle needs a different check
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
- * @return IQueryFunction
+ * @return string
* @since 13.0.0
*/
- public function emptyString($x): IQueryFunction {
+ public function emptyString($x): string {
return $this->isNull($x);
}
@@ -151,10 +151,10 @@ class OCIExpressionBuilder extends ExpressionBuilder {
* Creates a `$x <> ''` statement, because Oracle needs a different check
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
- * @return IQueryFunction
+ * @return string
* @since 13.0.0
*/
- public function nonEmptyString($x): IQueryFunction {
+ public function nonEmptyString($x): string {
return $this->isNotNull($x);
}
@@ -182,14 +182,14 @@ class OCIExpressionBuilder extends ExpressionBuilder {
/**
* @inheritdoc
*/
- public function like($x, $y, $type = null): IQueryFunction {
- return new QueryFunction(parent::like($x, $y, $type) . " ESCAPE '\\'");
+ public function like($x, $y, $type = null): string {
+ return parent::like($x, $y, $type) . " ESCAPE '\\'";
}
/**
* @inheritdoc
*/
- public function iLike($x, $y, $type = null): IQueryFunction {
+ public function iLike($x, $y, $type = null): string {
return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y));
}
}
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php
index cbebe97ae87..0fba5363a28 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php
@@ -52,9 +52,9 @@ class PgSqlExpressionBuilder extends ExpressionBuilder {
/**
* @inheritdoc
*/
- public function iLike($x, $y, $type = null): IQueryFunction {
+ public function iLike($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
- return new QueryFunction($this->expressionBuilder->comparison($x, 'ILIKE', $y));
+ return $this->expressionBuilder->comparison($x, 'ILIKE', $y);
}
}
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php
index 5425138fa6c..289aa09b003 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php
@@ -23,18 +23,15 @@
*/
namespace OC\DB\QueryBuilder\ExpressionBuilder;
-use OC\DB\QueryBuilder\QueryFunction;
-use OCP\DB\QueryBuilder\IQueryFunction;
-
class SqliteExpressionBuilder extends ExpressionBuilder {
/**
* @inheritdoc
*/
- public function like($x, $y, $type = null): IQueryFunction {
- return new QueryFunction(parent::like($x, $y, $type) . " ESCAPE '\\'");
+ public function like($x, $y, $type = null): string {
+ return parent::like($x, $y, $type) . " ESCAPE '\\'";
}
- public function iLike($x, $y, $type = null): IQueryFunction {
- return new QueryFunction($this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type));
+ public function iLike($x, $y, $type = null): string {
+ return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type);
}
}
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index d991cbd1dd5..e81ba61b3a7 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -715,12 +715,11 @@ class QueryBuilder implements IQueryBuilder {
* @param string $fromAlias The alias that points to a from clause.
* @param string $join The table name to join.
* @param string $alias The alias of the join table.
- * @param string|IQueryFunction|ICompositeExpression|null $condition The condition for the join.
+ * @param string|ICompositeExpression|null $condition The condition for the join.
*
* @return $this This QueryBuilder instance.
*/
public function join($fromAlias, $join, $alias, $condition = null) {
- $condition = $condition !== null ? (string)$condition : null;
$this->queryBuilder->join(
$this->quoteAlias($fromAlias),
$this->getTableName($join),
@@ -744,12 +743,11 @@ class QueryBuilder implements IQueryBuilder {
* @param string $fromAlias The alias that points to a from clause.
* @param string $join The table name to join.
* @param string $alias The alias of the join table.
- * @param string|IQueryFunction|ICompositeExpression|null $condition The condition for the join.
+ * @param string|ICompositeExpression|null $condition The condition for the join.
*
* @return $this This QueryBuilder instance.
*/
public function innerJoin($fromAlias, $join, $alias, $condition = null) {
- $condition = $condition !== null ? (string)$condition : null;
$this->queryBuilder->innerJoin(
$this->quoteAlias($fromAlias),
$this->getTableName($join),
@@ -773,12 +771,11 @@ class QueryBuilder implements IQueryBuilder {
* @param string $fromAlias The alias that points to a from clause.
* @param string $join The table name to join.
* @param string $alias The alias of the join table.
- * @param string|IQueryFunction|ICompositeExpression|null $condition The condition for the join.
+ * @param string|ICompositeExpression|null $condition The condition for the join.
*
* @return $this This QueryBuilder instance.
*/
public function leftJoin($fromAlias, $join, $alias, $condition = null) {
- $condition = $condition !== null ? (string)$condition : null;
$this->queryBuilder->leftJoin(
$this->quoteAlias($fromAlias),
$this->getTableName($join),
@@ -802,12 +799,11 @@ class QueryBuilder implements IQueryBuilder {
* @param string $fromAlias The alias that points to a from clause.
* @param string $join The table name to join.
* @param string $alias The alias of the join table.
- * @param string|IQueryFunction|ICompositeExpression|null $condition The condition for the join.
+ * @param string|ICompositeExpression|null $condition The condition for the join.
*
* @return $this This QueryBuilder instance.
*/
public function rightJoin($fromAlias, $join, $alias, $condition = null) {
- $condition = $condition !== null ? (string)$condition : null;
$this->queryBuilder->rightJoin(
$this->quoteAlias($fromAlias),
$this->getTableName($join),