-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.transform() fails to drop column if table is part of a view #586
Comments
More notes in here: Not all Python/SQLite installations exhibit this problem by default! It turns out this is controlled by the If that PRAGMA is turned on (default in newer SQLites) then Here's a one-liner to test if it is on or not: python -c 'import sqlite3; print(sqlite3.connect(":memory:").execute("PRAGMA legacy_alter_table").fetchall())' |
Options:
I'm on the fence as to which of these I like the most. I'm tempted to go with the one which just drops VIEWS and recreates them all the time, because it feels simpler. |
I shipped the view recreating fix in |
Just noting that the fix @simonw mentions is here in datasette-edit-schema. I'm using views that reference tables that are changing, so I'm likely to want this fix. |
The documentation for the Regardless, using the pragma seems a bad idea to me, because:
The |
I got this error trying to drop a column from a table that was part of a SQL view:
Upon further investigation I found that this pattern seemed to fix it:
So grab a copy of any view that might reference this table, start a transaction, drop those views, run the transform, recreate the views again.
Originally posted by @simonw in simonw/datasette-edit-schema#35 (comment)
The text was updated successfully, but these errors were encountered: