Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use getLengthExpression to measure field length instead of like #31696

Merged
merged 5 commits into from
Mar 29, 2022

Conversation

come-nc
Copy link
Contributor

@come-nc come-nc commented Mar 24, 2022

The use of the LIKE with _ does not work on oracle as it measure length in chars instead of bytes.

Signed-off-by: Côme Chilliet come.chilliet@nextcloud.com

@come-nc come-nc added this to the Nextcloud 24 milestone Mar 24, 2022
@come-nc come-nc self-assigned this Mar 24, 2022
@come-nc come-nc requested review from nickvergessen and blizzz March 24, 2022 10:14
@come-nc come-nc added the 3. to review Waiting for reviews label Mar 24, 2022
@@ -127,9 +127,10 @@ protected function handleIDs(string $table, bool $emitHooks) {

protected function getSelectQuery(string $table): IQueryBuilder {
$qb = $this->dbc->getQueryBuilder();
$lengthExpr = $this->dbc->getDatabasePlatform()->getLengthExpression('owncloud_name');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be moved to the query builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stole it from #31683

First question is does it actually work on all DBs, and does it compute length in bytes or chars.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, something for later then and we just add a unit test to make sure it does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So from what I gather this actually evaluates to LENGTH everywhere which is not what we want: https://github.com/doctrine/dbal/blob/3.3.x/src/Platforms/AbstractPlatform.php#L823

We need LENGTHB which exists on both Oracle and MariaDB.
Postgres needs OCTET_LENGTH I think. (MariaDB also supports it, but Oracle does not)

@come-nc come-nc force-pushed the fix/user_ldap-fix-migration-lengthcheck-oracle branch from 25ed0ed to 2da5a2a Compare March 24, 2022 13:17
@come-nc
Copy link
Contributor Author

come-nc commented Mar 24, 2022

/rebase

@nextcloud-command nextcloud-command force-pushed the fix/user_ldap-fix-migration-lengthcheck-oracle branch from bceb911 to e44378d Compare March 24, 2022 18:48
@PVince81
Copy link
Member

/rebase

come-nc added 4 commits March 24, 2022 20:35
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@nextcloud-command nextcloud-command force-pushed the fix/user_ldap-fix-migration-lengthcheck-oracle branch from e44378d to 25af856 Compare March 24, 2022 20:35
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc
Copy link
Contributor Author

come-nc commented Mar 28, 2022

Finally have a working implementation of both octetLength and charLength for all tested databases 🥳

Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, crazy stuff 👍

@come-nc come-nc merged commit 4a4f250 into master Mar 29, 2022
@come-nc come-nc deleted the fix/user_ldap-fix-migration-lengthcheck-oracle branch March 29, 2022 07:38
@blizzz blizzz mentioned this pull request Mar 31, 2022
@come-nc
Copy link
Contributor Author

come-nc commented Dec 13, 2022

/backport to stable22

@come-nc
Copy link
Contributor Author

come-nc commented Dec 13, 2022

/backport to stable23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants