github
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/simonw/sqlite-utils/issues/586#issuecomment-1683396150 | https://api.github.com/repos/simonw/sqlite-utils/issues/586 | 1683396150 | IC_kwDOCGYnMM5kVpY2 | 9599 | 2023-08-18T06:02:18Z | 2023-08-18T06:06:31Z | OWNER | More notes in here: - https://github.com/simonw/datasette-edit-schema/issues/35#issuecomment-1683392873 Not all Python/SQLite installations exhibit this problem by default! It turns out this is controlled by the `legacy_alter_table` pragma: https://sqlite.org/pragma.html#pragma_legacy_alter_table If that PRAGMA is turned on (default in newer SQLites) then `alter table` will error if you try to rename a table that is referenced in a view. Here's a one-liner to test if it is on or not: ```bash python -c 'import sqlite3; print(sqlite3.connect(":memory:").execute("PRAGMA legacy_alter_table").fetchall())' ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1856075668 | |
https://github.com/simonw/sqlite-utils/issues/586#issuecomment-1683398866 | https://api.github.com/repos/simonw/sqlite-utils/issues/586 | 1683398866 | IC_kwDOCGYnMM5kVqDS | 9599 | 2023-08-18T06:05:50Z | 2023-08-18T06:06:42Z | OWNER | Options: - Provide a `recreate_views: bool` parameter to `table.transform()` controlling if views that might reference this table are stashed and dropped and recreated within a transaction as part of the operation. But should that be `True` or `False` by default? - Read that `PRAGMA` and automatically do that view workaround if it's turned on - Toggle that `PRAGMA` off for the duration of the `.transform()` operation and on again at the end. Does it only affect the current connection? - Try the `transform()` in a transaction, detect the `"error in view"`, `"no such table"`error, if spotted then do the VIEW workaround and try again 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. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1856075668 | |
https://github.com/simonw/sqlite-utils/issues/586#issuecomment-1683404978 | https://api.github.com/repos/simonw/sqlite-utils/issues/586 | 1683404978 | IC_kwDOCGYnMM5kVriy | 9599 | 2023-08-18T06:13:46Z | 2023-08-18T06:13:46Z | OWNER | I shipped the view recreating fix in `datasette-edit-schema`, so at least I can start exercising that fix and see if it has any weird issues. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1856075668 |