Skip to content

Fix transform() dropping AUTOINCREMENT from INTEGER PRIMARY KEY columns#793

Open
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-transform-drops-autoincrement
Open

Fix transform() dropping AUTOINCREMENT from INTEGER PRIMARY KEY columns#793
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-transform-drops-autoincrement

Conversation

@ikatyal2110

@ikatyal2110 ikatyal2110 commented Jul 12, 2026

Copy link
Copy Markdown

Calling .transform() on a table with INTEGER PRIMARY KEY AUTOINCREMENT silently dropped the AUTOINCREMENT keyword, meaning deleted row IDs could be reused in subsequent inserts. This fix detects AUTOINCREMENT in the existing table schema and preserves it in the recreated table by passing it through create_table_sql(). Fixes #602


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

Calling .transform() on a table with INTEGER PRIMARY KEY AUTOINCREMENT
recreated the table without the AUTOINCREMENT keyword, silently changing
the table's behaviour so that deleted row IDs could be reused.

The fix adds an autoincrement parameter to create_table_sql() and detects
AUTOINCREMENT in the existing schema before calling it from transform_sql().
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.

sqlite-utils transform removes the AUTOINCREMENT keyword

1 participant