SQLite driver does not allow for case insensitive LIKE comparisons on non-ASCII characters

Created on 3 November 2015, about 9 years ago
Updated 7 January 2025, 16 days ago

Follow-up to #2584243: Make Drupal handle path aliases in a consistent and case-insensitive fashion on all database drivers

Problem/Motivation

It is currently not possible to do a case-insensitive LIKE comparison on values with non-ASCII characters, SQLite needs to be compiled with the ICU extension for this:

(18) Case-insensitive matching of Unicode characters does not work.

The default configuration of SQLite only supports case-insensitive comparisons of ASCII characters. The reason for this is that doing full Unicode case-insensitive comparisons and case conversions requires tables and logic that would nearly double the size of the SQLite library. The SQLite developers reason that any application that needs full Unicode case support probably already has the necessary tables and functions and so SQLite should not take up space to duplicate this ability.

Instead of providing full Unicode case support by default, SQLite provides the ability to link against external Unicode comparison and conversion routines. The application can overload the built-in NOCASE collating sequence (using sqlite3_create_collation()) and the built-in like(), upper(), and lower() functions (using sqlite3_create_function()). The SQLite source code includes an "ICU" extension that does these overloads. Or, developers can write their own overloads based on their own Unicode-aware comparison routines already contained within their project.

Ref https://www.sqlite.org/faq.html#q18

Proposed resolution

TBD

One workaround may be to do UPPER(x) = UPPER(y) COLLATE NOCASE_UTF8, where NOCASE_UTF8 is the custom collation defined in the PDO driver.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component

sqlite db driver

Created by

🇳🇱Netherlands stefan.r

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024