Skip to content

Commit bbbb251

Browse files
come-ncbackportbot-nextcloud[bot]
authored andcommitted
Fix LENGTH function name across databases
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent e5a5a18 commit bbbb251

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function octetLength($field, $alias = ''): IQueryFunction {
8888
public function charLength($field, $alias = ''): IQueryFunction {
8989
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
9090
$quotedName = $this->helper->quoteColumnName($field);
91-
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
91+
return new QueryFunction('CHAR_LENGTH(' . $quotedName . ')' . $alias);
9292
}
9393

9494
public function max($field): IQueryFunction {

lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ public function octetLength($field, $alias = ''): IQueryFunction {
4444
$quotedName = $this->helper->quoteColumnName($field);
4545
return new QueryFunction('LENGTH(CAST(' . $quotedName . ' as BLOB))' . $alias);
4646
}
47+
48+
public function charLength($field, $alias = ''): IQueryFunction {
49+
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
50+
$quotedName = $this->helper->quoteColumnName($field);
51+
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
52+
}
4753
}

0 commit comments

Comments
 (0)