mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Accept multipe args on concat
Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
parent
d232dc85ff
commit
814924a787
5 changed files with 33 additions and 9 deletions
|
|
@ -50,8 +50,13 @@ class FunctionBuilder implements IFunctionBuilder {
|
|||
return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')');
|
||||
}
|
||||
|
||||
public function concat($x, $y): IQueryFunction {
|
||||
return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')');
|
||||
public function concat($x, ...$expr): IQueryFunction {
|
||||
$args = func_get_args();
|
||||
$list = [];
|
||||
foreach ($args as $item) {
|
||||
$list[] = $this->helper->quoteColumnName($item);
|
||||
}
|
||||
return new QueryFunction(sprintf('CONCAT(%s)', implode(', ', $list)));
|
||||
}
|
||||
|
||||
public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
|
||||
|
|
|
|||
|
|
@ -73,6 +73,15 @@ class OCIFunctionBuilder extends FunctionBuilder {
|
|||
return parent::least($x, $y);
|
||||
}
|
||||
|
||||
public function concat($x, ...$expr): IQueryFunction {
|
||||
$args = func_get_args();
|
||||
$list = [];
|
||||
foreach ($args as $item) {
|
||||
$list[] = $this->helper->quoteColumnName($item);
|
||||
}
|
||||
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
|
||||
}
|
||||
|
||||
public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
|
||||
$orderByClause = ' WITHIN GROUP(ORDER BY NULL)';
|
||||
if (is_null($separator)) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,13 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
|
|||
use OCP\DB\QueryBuilder\IQueryFunction;
|
||||
|
||||
class PgSqlFunctionBuilder extends FunctionBuilder {
|
||||
public function concat($x, $y): IQueryFunction {
|
||||
return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')');
|
||||
public function concat($x, ...$expr): IQueryFunction {
|
||||
$args = func_get_args();
|
||||
$list = [];
|
||||
foreach ($args as $item) {
|
||||
$list[] = $this->helper->quoteColumnName($item);
|
||||
}
|
||||
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
|
||||
}
|
||||
|
||||
public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,13 @@ use OC\DB\QueryBuilder\QueryFunction;
|
|||
use OCP\DB\QueryBuilder\IQueryFunction;
|
||||
|
||||
class SqliteFunctionBuilder extends FunctionBuilder {
|
||||
public function concat($x, $y): IQueryFunction {
|
||||
return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')');
|
||||
public function concat($x, ...$expr): IQueryFunction {
|
||||
$args = func_get_args();
|
||||
$list = [];
|
||||
foreach ($args as $item) {
|
||||
$list[] = $this->helper->quoteColumnName($item);
|
||||
}
|
||||
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
|
||||
}
|
||||
|
||||
public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ interface IFunctionBuilder {
|
|||
/**
|
||||
* Combines two input strings
|
||||
*
|
||||
* @param string|ILiteral|IParameter|IQueryFunction $x The first input string
|
||||
* @param string|ILiteral|IParameter|IQueryFunction $y The second input string
|
||||
* @param string|ILiteral|IParameter|IQueryFunction $x Expressions or literal strings
|
||||
* @param string|ILiteral|IParameter|IQueryFunction ...$exprs Expressions or literal strings
|
||||
*
|
||||
* @return IQueryFunction
|
||||
* @since 12.0.0
|
||||
*/
|
||||
public function concat($x, $y): IQueryFunction;
|
||||
public function concat($x, ...$expr): IQueryFunction;
|
||||
|
||||
/**
|
||||
* Returns a string which is the concatenation of all non-NULL values of X
|
||||
|
|
|
|||
Loading…
Reference in a new issue