-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Use getLengthExpression to measure field length instead of like #31696
Conversation
@@ -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'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
25ed0ed
to
2da5a2a
Compare
/rebase |
bceb911
to
e44378d
Compare
/rebase |
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>
e44378d
to
25af856
Compare
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Finally have a working implementation of both octetLength and charLength for all tested databases 🥳 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, crazy stuff 👍
/backport to stable22 |
/backport to stable23 |
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