Merge pull request #54251 from nextcloud/backport/54203/stable30

[stable30] fix: fix oci string length with empty strings
pull/54257/head
Stephan Orbaugh 2025-08-07 15:21:44 +07:00 committed by GitHub
commit d308e61847
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

@ -81,12 +81,12 @@ class OCIFunctionBuilder extends FunctionBuilder {
public function octetLength($field, $alias = ''): IQueryFunction {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
$quotedName = $this->helper->quoteColumnName($field);
return new QueryFunction('LENGTHB(' . $quotedName . ')' . $alias);
return new QueryFunction('COALESCE(LENGTHB(' . $quotedName . '), 0)' . $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);
return new QueryFunction('COALESCE(LENGTH(' . $quotedName . '), 0)' . $alias);
}
}

@ -371,6 +371,7 @@ class FunctionBuilderTest extends TestCase {
$result = $query->execute();
$column = $result->fetchOne();
$result->closeCursor();
$this->assertNotNull($column);
$this->assertEquals($bytes, $column);
}