Skip to content

transform() preserves column COLLATE clauses - #966

Closed
Naingzwehtut wants to merge 1 commit into
simonw:mainfrom
Naingzwehtut:fix-transform-collate
Closed

Naingzwehtut wants to merge 1 commit into
simonw:mainfrom
Naingzwehtut:fix-transform-collate

Conversation

@Naingzwehtut

@Naingzwehtut Naingzwehtut commented Nov 27, 2026 •

Copy link
Copy Markdown

Closes #954

table.transform() now keeps each column's COLLATE clause. PRAGMA table_info doesn't report collations, so they're read from the schema SQL with a new parse_column_collations() in create_table_parser.py, the same way CHECK and UNIQUE constraints already are. Collations follow renamed columns and are dropped with dropped columns.

db.execute("CREATE TABLE people (id INTEGER PRIMARY KEY, name TEXT COLLATE NOCASE)")
db["people"].transform(types={"id": int})
db["people"].schema
# before: "name" TEXT
# after:  "name" TEXT COLLATE "NOCASE"

Tests: parser cases (quoted names, COLLATE inside CHECK, defaults, comments and table-level UNIQUE are ignored) and a transform test that renames and drops columns and checks the comparisons still behave. Full suite passes locally, and black, flake8, mypy, pyright and cog are clean.

AI disclosure: this change, its tests and this description were written with Claude Code (Claude Opus 5.5) and reviewed before opening.


📚 Documentation preview 📚: https://sqlite-utils--966.org.readthedocs.build/en/966/

AI-assisted: written with Claude Code (Claude Opus 5.5).
@simonw

simonw commented Nov 29, 2026

Copy link
Copy Markdown
Owner

I'm using this PR instead:

@simonw simonw closed this Nov 29, 2026
@Naingzwehtut
Naingzwehtut deleted the fix-transform-collate branch November 30, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

table.transform() drops column COLLATE

2 participants