Text Folding
Folds text for case-insensitive (and, if the implementation wants, accent-insensitive) matching of facet filters. The same folding must be applied on both sides of a comparison: column wraps the database column in SQL, value transforms the text on the client side.
Used by:
Facet.Type.TEXT filters when the facet is not case-sensitive: the generated condition is
column(col) likeOperator ?. The bound pattern is built from the typed text split at the wildcards: each literal piece goes through likeValue and is then escaped, so a folding never sees, removes or alters a wildcard or an escape.Facet.Type.ENUM filters, which match display names on the client side by comparing value of the display name with value of the typed text.
Set it once per Stormify instance through Stormify.textFolding. The default, DEFAULT, is the plain case-insensitive matching of the dialect.
An implementation for a specific language typically uppercases the column and removes diacritics with a database function (TRANSLATE, unaccent, …) in column, and does the same with the platform's text utilities in value. The two must produce the same text for the same input, otherwise filters miss rows.
stormify.textFolding = object : TextFolding {
override fun column(columnExpr: String, dialect: SqlDialect) = "UPPER($columnExpr)"
override fun value(text: String) = text.uppercase()
}Functions
Returns the SQL expression that folds columnExpr on the database side.
The operator that compares the folded column with the bound text. Defaults to LIKE.