Fix LENGTH function name across databases

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2022-03-28 00:01:17 +02:00
parent 6e3cd43903
commit 6185e326dc
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
3 changed files with 13 additions and 1 deletions

View file

@ -88,7 +88,7 @@ class FunctionBuilder implements IFunctionBuilder {
public function charLength($field, $alias = ''): IQueryFunction {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
return new QueryFunction('CHAR_LENGTH(' . $quotedName . ')' . $alias);
}
public function max($field): IQueryFunction {

View file

@ -78,4 +78,10 @@ class OCIFunctionBuilder extends FunctionBuilder {
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTHB(' . $quotedName . ')' . $alias);
}
public function charLength($field, $alias = ''): IQueryFunction {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
}
}

View file

@ -44,4 +44,10 @@ class SqliteFunctionBuilder extends FunctionBuilder {
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTH(CAST(' . $quotedName . ' as BLOB))' . $alias);
}
public function charLength($field, $alias = ''): IQueryFunction {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
}
}