sqlite-utils/sqlite_utils
Claude 4d6d51ad02
Fix .transform() raising TransformError on column-level UNIQUE constraints
SQLite backs a column-level UNIQUE constraint with an auto-index whose
sql in sqlite_master is NULL. The index-rebuild step in transform_sql()
treated any NULL-sql index as an error, causing TransformError on tables
with UNIQUE columns.

The fix adds a 'unique' parameter to create_table_sql so the constraint
is reproduced as an inline UNIQUE column attribute in the new CREATE
TABLE statement. In transform_sql(), auto-UNIQUE indices (origin='u')
are collected before the CREATE TABLE call and passed via unique=; the
index rebuild loop then skips them with a continue instead of raising.
Column renames are applied to the constraint; dropping a UNIQUE column
drops its constraint silently.

Fixes #762
2026-07-09 22:35:55 +00:00
..
__init__.py New migrations system, ported from sqlite-migrate (#754) 2026-06-21 09:40:21 -07:00
__main__.py Support 'python -m sqlite_utils', closes #368 2022-01-08 18:33:22 -08:00
cli.py drop-index command and table.drop_index(index_name) 2026-07-07 21:00:43 -07:00
db.py Fix .transform() raising TransformError on column-level UNIQUE constraints 2026-07-09 22:35:55 +00:00
hookspecs.py More type annotations (#697) 2025-12-16 22:11:47 -08:00
migrations.py migrate --stop-before an already-applied migration is now an error 2026-07-06 21:50:05 -07:00
plugins.py fix: Plugins are still loaded when running tests (#719) 2026-06-21 16:14:45 -07:00
py.typed py.typed file so mypy picks up the types, closes #331 2021-11-14 15:21:04 -08:00
recipes.py More type annotations (#697) 2025-12-16 22:11:47 -08:00
utils.py Preserve duplicate column names in query results 2026-07-05 21:20:39 -07:00