Skip to content

Fix all the places that currently use .inspect() data #420

@simonw

Description

@simonw

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)
  • DatabaseDownload file path
  • sortable_columns_for_table() uses it to find the columns in a table
  • expandable_columns() uses it to find foreign keys
  • expand_foreign_keys() uses it to find foreign keys
  • display_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 columns
  • TableView.data uses 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.data uses it for primary keys
  • foreign_key_tables() uses it for foreign keys
  • DatabaseView list of tables
  • IndexView

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions