mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
Explicitly cast char in the query builder
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
130d3bd8d3
commit
a169ca306e
4 changed files with 22 additions and 0 deletions
|
|
@ -26,7 +26,9 @@
|
|||
namespace OC\DB\QueryBuilder\ExpressionBuilder;
|
||||
|
||||
use OC\DB\ConnectionAdapter;
|
||||
use OC\DB\QueryBuilder\QueryFunction;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\DB\QueryBuilder\IQueryFunction;
|
||||
|
||||
class MySqlExpressionBuilder extends ExpressionBuilder {
|
||||
|
||||
|
|
@ -52,4 +54,21 @@ class MySqlExpressionBuilder extends ExpressionBuilder {
|
|||
$y = $this->helper->quoteColumnName($y);
|
||||
return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->collation . ' LIKE', $y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a IQueryFunction that casts the column to the given type
|
||||
*
|
||||
* @param string|IQueryFunction $column
|
||||
* @param mixed $type One of IQueryBuilder::PARAM_*
|
||||
* @psalm-param IQueryBuilder::PARAM_* $type
|
||||
* @return IQueryFunction
|
||||
*/
|
||||
public function castColumn($column, $type): IQueryFunction {
|
||||
switch ($type) {
|
||||
case IQueryBuilder::PARAM_STR:
|
||||
return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS CHAR)');
|
||||
default:
|
||||
return parent::castColumn($column, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ class OCIExpressionBuilder extends ExpressionBuilder {
|
|||
*
|
||||
* @param string|IQueryFunction $column
|
||||
* @param mixed $type One of IQueryBuilder::PARAM_*
|
||||
* @psalm-param IQueryBuilder::PARAM_* $type
|
||||
* @return IQueryFunction
|
||||
*/
|
||||
public function castColumn($column, $type): IQueryFunction {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class PgSqlExpressionBuilder extends ExpressionBuilder {
|
|||
*
|
||||
* @param string|IQueryFunction $column
|
||||
* @param mixed $type One of IQueryBuilder::PARAM_*
|
||||
* @psalm-param IQueryBuilder::PARAM_* $type
|
||||
* @return IQueryFunction
|
||||
*/
|
||||
public function castColumn($column, $type): IQueryFunction {
|
||||
|
|
|
|||
|
|
@ -433,6 +433,7 @@ interface IExpressionBuilder {
|
|||
*
|
||||
* @param string|IQueryFunction $column
|
||||
* @param mixed $type One of IQueryBuilder::PARAM_*
|
||||
* @psalm-param IQueryBuilder::PARAM_* $type
|
||||
* @return IQueryFunction
|
||||
* @since 9.0.0
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue