Repository navigation
Conversation
table.transform() rebuilt each column from PRAGMA table_info, which does not report collation, so a column declared "name TEXT COLLATE NOCASE" became plain "name TEXT" and comparisons on it turned case-sensitive. Parse column collations from the existing schema with a new parse_column_collations() helper and pass them to create_table_sql() via a private _column_collations argument. Collations follow renamed columns and are dropped with dropped columns. Refs simonw#954
Mo0nl19ht
force-pushed
the
fix-transform-collate
branch
from
November 17, 2026 08:06
0b71df5 to
6dec072
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes:
table.transform()rebuilds columns fromPRAGMA table_info, which does not report collation, so a column declaredname TEXT COLLATE NOCASEbecamename TEXTand comparisons on it turned case-sensitive. (A column-levelUNIQUEalready kept its collation, becauseparse_uniques()reads it, but the column itself lost it.)Change
A new
parse_column_collations()increate_table_parser.pyreads each column'sCOLLATEfrom the schema. It reuses the collation scan that_column_uniques()already did, now moved into a_column_collation()helper.transform_sql()passes the result tocreate_table_sql()through a private_column_collationsargument, the same way_column_commentsworks. Collations follow renamed columns and are dropped with dropped columns. Everything else about the generated schema is unchanged.The transform section of
docs/python-api.rstnow mentions that column collations are preserved.Tests
test_parse_column_collationsintests/test_create_table_parser.py: quoted names,VARCHAR(10), and ignoringCOLLATEinsideCHECK, comments and table-levelUNIQUEtest_transform_preserves_column_collationandtest_transform_collation_follows_renamed_column_and_dropintests/test_transform.pytest_transform_preserves_column_collationintests/test_cli.py, forsqlite-utils transformThe new tests fail on
mainand pass with this change. Locally the full suite passes (1505 passed, 16 skipped), and so do black, flake8, mypy, pyright, cog and codespell.ty check sqlite_utilsreports oneredundant-castininsert_all()(db.py:4792onmain). It fails the same way onmainwith ty 0.0.104, and the latestmainCI run fails at the samerun tystep, so it is unrelated to this change.Written with help from Claude Code.
📚 Documentation preview 📚: https://sqlite-utils--955.org.readthedocs.build/en/955/