⚡ Sangsakala Proxy 🏠 Home
Skip to content

Update CHECK constraint expressions when renaming a column - #4232

Open
deepsidhu1313 wants to merge 1 commit into
sqlitebrowser:masterfrom
deepsidhu1313:fix/check-constraint-rename
Open

deepsidhu1313 wants to merge 1 commit into
sqlitebrowser:masterfrom
deepsidhu1313:fix/check-constraint-rename

Conversation

@deepsidhu1313

Copy link
Copy Markdown
Contributor

When a column was renamed in the Edit Table dialog, the column names referenced in column and table CHECK constraint expressions were not updated. SQLite itself rewrites them during ALTER TABLE RENAME COLUMN, but the dialog's table definition still contained the old name, so alterTable() saw a difference and recreated the table with a CHECK referring to the old, no longer existing column.

Table::renameKeyInAllConstraints() now also rewrites the column name in all CHECK expressions, leaving string literals, comments and function names alone.

See issue #1817

When a column was renamed in the Edit Table dialog, the column names
referenced in column and table CHECK constraint expressions were not
updated. SQLite itself rewrites them during ALTER TABLE RENAME COLUMN,
but the dialog's table definition still contained the old name, so
alterTable() saw a difference and recreated the table with a CHECK
referring to the old, no longer existing column.

Table::renameKeyInAllConstraints() now also rewrites the column name in
all CHECK expressions, leaving string literals, comments and function
names alone.

See issue sqlitebrowser#1817

This branch has not been deployed

No deployments
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.

2 participants