SQLite NOCASE and canonical caseless keys Executed: 2026-11-05. Environment: macOS 27.0.1 arm64, CPython 3.12.14, SQLite runtime 3.53.1, Unicode data 15.0.0. Run in the directory containing this file: python3 sqlite-nocase-lab.py > rerun.json Use Python 3.12 to match the recorded transaction behavior and version metadata. The script uses only the standard library and in-memory SQLite databases. It accepts no input, loads no extensions, accesses no network, and writes no database files. The shell redirection saves its stdout. An assertion failure exits unsuccessfully. Archive contents: sqlite-nocase-lab.py Complete reproduction. sqlite-nocase-results.json Output recorded in the environment above. sqlite-nocase-README.txt This file. What it tests: - Ten pairs: SQL equality with NOCASE, actual NOCASE UNIQUE insertions, and actual UNIQUE insertions with an application-computed comparison key. - A column's default collation versus an explicit BINARY query, without changing the uniqueness rule. Also LIKE pattern semantics, SQLite lower(), and two NULLs in a nullable UNIQUE column. - NFD(casefold(NFD(text))) preserves accents, width distinctions in the tested ASCII/fullwidth pair, and trailing space, while recognizing the tested canonical equivalence and case variants. - Six legacy rows contain two groups that collide under the new key. An explicit transaction copying all rows fails and rolls back the new table; the original six rows remain. A separately specified four-row teaching selection then copies successfully. No legacy row is deleted. - The key lookup returns the original display name. A duplicate insertion, a NULL key and a conflicting rename are rejected. Both columns of the renamed row retain their original values after the rejected statement. - A deliberately unrelated key can bypass semantic deduplication. That insertion is rolled back. UNIQUE checks the stored key, not its correspondence with the display name. The JSON includes code points to disambiguate visually identical strings. Runtime versions may differ on another machine. This lab does not test ICU, locale-specific sorting, Unicode security policies, concurrent connections, file durability, production migrations, foreign keys or performance. Primary references: https://www.sqlite.org/datatype3.html#collating_sequences https://www.sqlite.org/lang_createindex.html https://www.sqlite.org/lang_expr.html#the_like_glob_regexp_match_and_extract_operators https://www.sqlite.org/lang_createtable.html#uniqueconst https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/ https://docs.python.org/3.12/library/stdtypes.html#str.casefold https://docs.python.org/3.12/library/sqlite3.html#how-to-use-the-connection-context-manager