[BUGFIX] Ensure case-insensitive `like()` and `notLike()` expression
Search- and filter functionaly usually uses `LIKE` or `NOT LIKE` SQL statements to search a provided search term in the database. Different dbms behave differently regarding search term casing. MySQL/MariaDB relies on chosen collation of the database-, table- and/or column level. Typical and recommended defaults on db side and by TYPO3 default settings are case-insensitive collations, which is the most common spread configuration. Based on this, most people assume search terms are searched case-insensitive, when using `LIKE` or `NOT LIKE` SQL statements. PostgresSQL on the other hand knows the keywords `LIKE` and `ILIKE`. The `ILIKE` keyword has to be used, when a case-insensitive search is wanted. The current implementation simply uses `LIKE` for all dbms, so searching with postgres is case sensitive, while it is usually case insensitive with MySQL/MariaDB. SQLite states `LIKE` is case-insensitive, which is basically correct. The limitation is, this only works for the 26 chars in the ASCII charset range, and not only for `LIKE` but also for the `UPPER()` and `LOWER()`. There should be a way to compile php extension sqlite with ICU support, enabling case awareness for more chars, but that's nothing we can expect people do and have by default. We cannot do much, so we leave some notes in the code regarding this detail. The patch changes ExpressionBuilder to use ILIKE on PostgresSQL to be in-line with the default MySQL/MariaDB behavior. Resolves: #98570 Releases: main, 11.5 Change-Id: I5a586a4bf46ee1b4699f4223fd4b19a0b9ae453b Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76085 Tested-by:core-ci <typo3@b13.com> Tested-by:
Stefan Bürk <stefan@buerk.tech> Reviewed-by:
Stefan Bürk <stefan@buerk.tech>
Showing
- typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php 17 additions, 4 deletions...e/Classes/Database/Query/Expression/ExpressionBuilder.php
- typo3/sysext/core/Tests/Functional/Database/Fixtures/DataSet/TestExpressionBuilderLikeAndNotLike.csv 4 additions, 0 deletions.../Fixtures/DataSet/TestExpressionBuilderLikeAndNotLike.csv
- typo3/sysext/core/Tests/Functional/Database/Query/Expression/ExpressionBuilderTest.php 197 additions, 3 deletions...ional/Database/Query/Expression/ExpressionBuilderTest.php
- typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php 6 additions, 5 deletions.../Unit/Database/Query/Expression/ExpressionBuilderTest.php
- typo3/sysext/indexed_search/Tests/Functional/Utility/LikeWildcardTest.php 4 additions, 0 deletions...exed_search/Tests/Functional/Utility/LikeWildcardTest.php
Please register or sign in to comment