Use getLengthExpression to measure field length instead of like

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2022-03-24 11:12:12 +01:00
parent 64d4790864
commit 774bb066d9
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -127,9 +127,10 @@ class Version1120Date20210917155206 extends SimpleMigrationStep {
protected function getSelectQuery(string $table): IQueryBuilder {
$qb = $this->dbc->getQueryBuilder();
$lengthExpr = $this->dbc->getDatabasePlatform()->getLengthExpression('owncloud_name');
$qb->select('owncloud_name', 'directory_uuid')
->from($table)
->where($qb->expr()->like('owncloud_name', $qb->createNamedParameter(str_repeat('_', 65) . '%'), Types::STRING));
->where($qb->expr()->gt($qb->createFunction($lengthExpr), '64', IQueryBuilder::PARAM_INT));
return $qb;
}