Skip to content

Commit d308e61

Browse files
authored
Merge pull request #54251 from nextcloud/backport/54203/stable30
[stable30] fix: fix oci string length with empty strings
2 parents 23f13ff + fead082 commit d308e61

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
8181
public function octetLength($field, $alias = ''): IQueryFunction {
8282
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
8383
$quotedName = $this->helper->quoteColumnName($field);
84-
return new QueryFunction('LENGTHB(' . $quotedName . ')' . $alias);
84+
return new QueryFunction('COALESCE(LENGTHB(' . $quotedName . '), 0)' . $alias);
8585
}
8686

8787
public function charLength($field, $alias = ''): IQueryFunction {
8888
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
8989
$quotedName = $this->helper->quoteColumnName($field);
90-
return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
90+
return new QueryFunction('COALESCE(LENGTH(' . $quotedName . '), 0)' . $alias);
9191
}
9292
}

tests/lib/DB/QueryBuilder/FunctionBuilderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ public function testCharLength(string $str, int $bytes) {
371371
$result = $query->execute();
372372
$column = $result->fetchOne();
373373
$result->closeCursor();
374+
$this->assertNotNull($column);
374375
$this->assertEquals($bytes, $column);
375376
}
376377

0 commit comments

Comments
 (0)