drift icon indicating copy to clipboard operation
drift copied to clipboard

String filter function contains() from manager class not fully working if the text is in Cyrillic

Open mnkhtrbukhbold opened this issue 3 months ago • 3 comments

names = await _db.managers.names.filter((f) => f.name.contains(query)).get();

This code does not work reliably when the name column contains Cyrillic characters (other non-Latin scripts were not tested). The search may match the first character correctly, but fails on subsequent characters. This issue does not occur with Latin text.

In contrast, the following query works correctly for both Latin and Cyrillic characters:

names = await (_db.select(_db.names)..where((x) => x.name.like('%$query%'))).get();

mnkhtrbukhbold avatar Nov 10 '25 08:11 mnkhtrbukhbold

Does it work if you set caseInsensitive: false on contains(), e.g. with filter((f) => f.name.contains(query, caseInsensitive: false))? Drift should generate the exact same SQL expression like with the manual like in that case.

simolus3 avatar Nov 12 '25 04:11 simolus3

Apologies for late reply, I have tested it again with caseInsensitve: false and it only works if I write every character as it is (upper case or lower case). This was not the case for Latin characters.

mnkhtrbukhbold avatar Nov 15 '25 21:11 mnkhtrbukhbold

Okay, but that's true for the .like too right? If you want to use the manager API with custom expressions, you can:

names = await _db.managers.names.filter((f) => f.name.column.like(...)).get();

simolus3 avatar Nov 16 '25 00:11 simolus3