From d14c971ad64c52aede28ab37e7b885d763936604 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Fri, 2 Oct 2020 18:59:53 +0200 Subject: [PATCH 1/4] Update signature for like/notLike/in/notIn $x is always passed to quoteColumnName hence ILiteral|IParameter|IQueryFunction are supported. Signed-off-by: Daniel Kesselberg --- .../QueryBuilder/ExpressionBuilder/ExpressionBuilder.php | 9 +++++---- lib/public/DB/QueryBuilder/IExpressionBuilder.php | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php index f4b434466e..4771609ad6 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php @@ -33,6 +33,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\IParameter; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryFunction; use OCP\IDBConnection; @@ -278,7 +279,7 @@ class ExpressionBuilder implements IExpressionBuilder { /** * Creates a LIKE() comparison expression with the given arguments. * - * @param string $x Field in string format to be inspected by LIKE() comparison. + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. * @param mixed $y Argument to be used in LIKE() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility @@ -309,7 +310,7 @@ class ExpressionBuilder implements IExpressionBuilder { /** * Creates a NOT LIKE() comparison expression with the given arguments. * - * @param string $x Field in string format to be inspected by NOT LIKE() comparison. + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. * @param mixed $y Argument to be used in NOT LIKE() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility @@ -325,7 +326,7 @@ class ExpressionBuilder implements IExpressionBuilder { /** * Creates a IN () comparison expression with the given arguments. * - * @param string $x The field in string format to be inspected by IN() comparison. + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. * @param string|array $y The placeholder or the array of values to be used by IN() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility @@ -341,7 +342,7 @@ class ExpressionBuilder implements IExpressionBuilder { /** * Creates a NOT IN () comparison expression with the given arguments. * - * @param string $x The field in string format to be inspected by NOT IN() comparison. + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility diff --git a/lib/public/DB/QueryBuilder/IExpressionBuilder.php b/lib/public/DB/QueryBuilder/IExpressionBuilder.php index e56eba3df0..0d629ad523 100644 --- a/lib/public/DB/QueryBuilder/IExpressionBuilder.php +++ b/lib/public/DB/QueryBuilder/IExpressionBuilder.php @@ -244,7 +244,7 @@ interface IExpressionBuilder { /** * Creates a LIKE() comparison expression with the given arguments. * - * @param string $x Field in string format to be inspected by LIKE() comparison. + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. * @param mixed $y Argument to be used in LIKE() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility @@ -257,7 +257,7 @@ interface IExpressionBuilder { /** * Creates a NOT LIKE() comparison expression with the given arguments. * - * @param string $x Field in string format to be inspected by NOT LIKE() comparison. + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. * @param mixed $y Argument to be used in NOT LIKE() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility @@ -283,7 +283,7 @@ interface IExpressionBuilder { /** * Creates a IN () comparison expression with the given arguments. * - * @param string $x The field in string format to be inspected by IN() comparison. + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. * @param string|array $y The placeholder or the array of values to be used by IN() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility @@ -296,7 +296,7 @@ interface IExpressionBuilder { /** * Creates a NOT IN () comparison expression with the given arguments. * - * @param string $x The field in string format to be inspected by NOT IN() comparison. + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility From 8fdb74bdd57ed5dda444e0a7b1b514815805b09b Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Fri, 2 Oct 2020 19:09:28 +0200 Subject: [PATCH 2/4] Update signature for in/notIn $y is always passed to quoteColumnName hence ILiteral|IParameter|IQueryFunction are supported. Signed-off-by: Daniel Kesselberg --- .../DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php | 4 ++-- lib/public/DB/QueryBuilder/IExpressionBuilder.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php index 4771609ad6..f2edea575a 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php @@ -327,7 +327,7 @@ class ExpressionBuilder implements IExpressionBuilder { * Creates a IN () comparison expression with the given arguments. * * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. - * @param string|array $y The placeholder or the array of values to be used by IN() comparison. + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * @@ -343,7 +343,7 @@ class ExpressionBuilder implements IExpressionBuilder { * Creates a NOT IN () comparison expression with the given arguments. * * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. - * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison. + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * diff --git a/lib/public/DB/QueryBuilder/IExpressionBuilder.php b/lib/public/DB/QueryBuilder/IExpressionBuilder.php index 0d629ad523..1484723409 100644 --- a/lib/public/DB/QueryBuilder/IExpressionBuilder.php +++ b/lib/public/DB/QueryBuilder/IExpressionBuilder.php @@ -284,7 +284,7 @@ interface IExpressionBuilder { * Creates a IN () comparison expression with the given arguments. * * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. - * @param string|array $y The placeholder or the array of values to be used by IN() comparison. + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * @@ -297,7 +297,7 @@ interface IExpressionBuilder { * Creates a NOT IN () comparison expression with the given arguments. * * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. - * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison. + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * From 64b10f61df7e1f5dd7d4f985f016b0e9122d4ba8 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Fri, 2 Oct 2020 19:15:34 +0200 Subject: [PATCH 3/4] Update signature for set also ILiteral and IQueryFunction are valid. Signed-off-by: Daniel Kesselberg --- lib/private/DB/QueryBuilder/QueryBuilder.php | 3 ++- lib/public/DB/QueryBuilder/IQueryBuilder.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index 4fde0fb451..0ebcf4425d 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -42,6 +42,7 @@ use OC\DB\QueryBuilder\FunctionBuilder\OCIFunctionBuilder; use OC\DB\QueryBuilder\FunctionBuilder\PgSqlFunctionBuilder; use OC\DB\QueryBuilder\FunctionBuilder\SqliteFunctionBuilder; use OC\SystemConfig; +use OCP\DB\QueryBuilder\ILiteral; use OCP\DB\QueryBuilder\IParameter; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryFunction; @@ -695,7 +696,7 @@ class QueryBuilder implements IQueryBuilder { * * * @param string $key The column to set. - * @param IParameter|string $value The value, expression, placeholder, etc. + * @param ILiteral|IParameter|IQueryFunction|string $value The value, expression, placeholder, etc. * * @return $this This QueryBuilder instance. */ diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php index 3a9c846043..91e22393ec 100644 --- a/lib/public/DB/QueryBuilder/IQueryBuilder.php +++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php @@ -522,7 +522,7 @@ interface IQueryBuilder { * * * @param string $key The column to set. - * @param IParameter|string $value The value, expression, placeholder, etc. + * @param ILiteral|IParameter|IQueryFunction|string $value The value, expression, placeholder, etc. * * @return $this This QueryBuilder instance. * @since 8.2.0 From 0e3ddf1b27eb84e0492e5db901dbf0efd4cfa3ef Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Sat, 3 Oct 2020 16:33:42 +0200 Subject: [PATCH 4/4] Add explicit typecast for $value. Signed-off-by: Daniel Kesselberg --- lib/private/DB/QueryBuilder/QueryBuilder.php | 4 ++-- lib/public/DB/QueryBuilder/IQueryBuilder.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index 0ebcf4425d..0e3f6f7dae 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -869,14 +869,14 @@ class QueryBuilder implements IQueryBuilder { * * * @param string $column The column into which the value should be inserted. - * @param string $value The value that should be inserted into the column. + * @param IParameter|string $value The value that should be inserted into the column. * * @return $this This QueryBuilder instance. */ public function setValue($column, $value) { $this->queryBuilder->setValue( $this->helper->quoteColumnName($column), - $value + (string) $value ); return $this; diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php index 91e22393ec..174ab1cc90 100644 --- a/lib/public/DB/QueryBuilder/IQueryBuilder.php +++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php @@ -651,7 +651,7 @@ interface IQueryBuilder { * * * @param string $column The column into which the value should be inserted. - * @param string $value The value that should be inserted into the column. + * @param IParameter|string $value The value that should be inserted into the column. * * @return $this This QueryBuilder instance. * @since 8.2.0