Property StringCollation

Assembly: redb.Core.dll

Unicode-aware case folding for case-insensitive text operations
(ContainsIgnoreCase, StartsWithIgnoreCase, EndsWithIgnoreCase,
ToLower, ToUpper).

Why it exists. Case folding is driven by the database's own rules, and those cover
only ASCII in two of the three providers. On PostgreSQL created with LC_CTYPE=C,
'Привет' ILIKE '%привет%' is false and lower('Привет') returns the string
unchanged. On SQLite this is unconditional: LIKE, lower(), upper() and
COLLATE NOCASE are ASCII-only in every database. MSSQL is unaffected because its
default collation is case-insensitive for all scripts.


What it fixes. Every script whose case mapping is one character to one character:
Cyrillic, Greek, Hungarian, Polish, Czech, French, most of German. There is no per-language
work; one setting covers all of them.


What it does NOT fix, and cannot, because no collation can:
foldings that change length (German ß against SS: upper() expands it,
pattern matching does not, so the two disagree); language-dependent foldings (Turkish
İ does not fold to i, and Turkish wants I→ı where every other
locale wants I→i); and insensitivity to diacritics (Müller against
muller), which is a different feature and is rejected outright by PostgreSQL for
pattern matching. See COLLATION.md.


Cost on PostgreSQL. Pro with on pushes an ignore-case
search onto _values as (_String COLLATE "und-x-icu") ILIKE, which the stock trigram
index over bare _String cannot serve: the search reads every row, silently. It needs an
index over the same collation,
CREATE INDEX ... USING gin ((_String COLLATE "und-x-icu") gin_trgm_ops); start-up logs a
Warning while it is missing. The free forms read no trigram index in either case. On a database
with a UTF-8 ctype plain ILIKE already folds every script and the setting is not needed; under
ctype C pg_trgm builds no trigram from non-ASCII text, so no index serves a non-ASCII pattern.

Default is null: behaviour is exactly what it was, on every provider.

public string? StringCollation { get; set; }