Skip to content

fix(library): use full Unicode case folding for search and sorting - #1579

Closed
sanketpatel32 wants to merge 1 commit into
TagStudioDev:mainfrom
sanketpatel32:devin/fix-unicode-search
Closed

sanketpatel32 wants to merge 1 commit into
TagStudioDev:mainfrom
sanketpatel32:devin/fix-unicode-search

Conversation

@sanketpatel32

Copy link
Copy Markdown

Summary

Fixes #1305. SQLite's built-in lower()/LIKE only fold ASCII letters, so search, tag lookup, and file name/path sorting were case-sensitive for non-ASCII characters (e.g. Ü, ß).

  • Registers a ts_lower() SQL function backed by Python's str.casefold() on every engine connection, and uses it everywhere case-insensitive matching or ordering happens: FILE_NAME/PATH sort modes, path: search constraints (LIKE and GLOB branches, plus compound-extension matching), search_tags (name, shorthand, aliases), search_field_templates, and tag-name resolution in the query parser (Tag.name/shorthand/TagAlias.name).
  • Also registers the regexp() SQL function referenced by the case-sensitive path: constraint (Entry.path.regexp_match), which previously crashed with no such function: regexp because nothing registered it.
  • Smartcase behavior is preserved: all-lowercase queries fold case, queries containing uppercase stay case-sensitive. Verified: path:strasse matches Straße_Foto.jpg; übung/ÜB both find tag Übung.

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality (320/320 tests passing; manually verified Unicode search + sorting)
    • PyInstaller executable

SQLite's lower()/LIKE only fold ASCII letters, so search and
filename/path sorting were case-sensitive for non-ASCII characters
(e.g. Ü, ß). Registers a ts_lower() SQL function backed by Python's
str.casefold() and uses it everywhere case-insensitive matching or
sorting is done (file name/path sorting, path constraints, tag and
field-template name search).

Also registers a regexp() SQL function used by the case-sensitive
path constraint, which previously referenced an unregistered
function.

Fixes TagStudioDev#1305
@CyanVoxel CyanVoxel closed this Nov 23, 2026
@TrigamDev TrigamDev added the Type: Invalid This doesn't seem right label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Uppercase and lowercase are treated as different letters for Cyrillic characters

3 participants