See #419: if Datasette is going to work against mutable SQLite files it can no longer assume that the .inspect() method will have cached the correct schema for all tables in all attached databases.
So everywhere in the code at the moment that relies on .inspect() data needs to be modified to use live introspection of the schema instead.
From a comment later on: here are the uses I need to fix as a checklist:
See #419: if Datasette is going to work against mutable SQLite files it can no longer assume that the
.inspect()method will have cached the correct schema for all tables in all attached databases.So everywhere in the code at the moment that relies on
.inspect()data needs to be modified to use live introspection of the schema instead.From a comment later on: here are the uses I need to fix as a checklist:
table_exists()info["file"]in.execute()resolve_db_name().database_url(database)DatabaseDownloadfile pathsortable_columns_for_table()uses it to find the columns in a tableexpandable_columns()uses it to find foreign keysexpand_foreign_keys()uses it to find foreign keysdisplay_columns_and_rows()uses it to find primary keys and foreign keys... but also has access to a cursor.description which it uses to list the columnsTableView.datauses it to lookup columns and primary keys and the table_rows_count (used if the thing isn't a view) and probably a few more things, this method is huge!RowView.datauses it for primary keysforeign_key_tables()uses it for foreign keysDatabaseViewlist of tablesIndexView