Skip to content
Snippets Groups Projects
Commit c4dd98c8 authored by Stefan Bürk's avatar Stefan Bürk
Browse files

[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: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
parent 871d71b2
Branches
Tags
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment