mirror of
https://github.com/simonw/datasette.git
synced 2026-06-01 14:47:00 +02:00
Use SQLiteTableType directly in SQL analysis
Remove the redundant SQLTableKind alias from the write SQL analysis model. Operation.table_kind and the analyzer cache now use the SQLite metadata classification type directly, making the source of table-kind values clearer.
This commit is contained in:
parent
b2b20b36c5
commit
cbe9594a3d
1 changed files with 3 additions and 4 deletions
|
|
@ -42,7 +42,6 @@ SQLTargetType = Literal[
|
|||
SQLTableOperation = Literal["read", "insert", "update", "delete"]
|
||||
SQLSchemaOperation = Literal["create", "drop"]
|
||||
SQLSchemaTargetType = Literal["index", "table", "trigger", "view", "virtual-table"]
|
||||
SQLTableKind = SQLiteTableType
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
|
@ -52,7 +51,7 @@ class Operation:
|
|||
database: str | None
|
||||
table: str | None
|
||||
sqlite_schema: str | None
|
||||
table_kind: SQLTableKind | None = None
|
||||
table_kind: SQLiteTableType | None = None
|
||||
target: str | None = None
|
||||
columns: tuple[str, ...] = ()
|
||||
source: str | None = None
|
||||
|
|
@ -428,7 +427,7 @@ def analyze_sql_tables(
|
|||
)
|
||||
return sqlite3.SQLITE_OK
|
||||
|
||||
table_kind_cache: dict[tuple[str | None, str], SQLTableKind | None] = {}
|
||||
table_kind_cache: dict[tuple[str | None, str], SQLiteTableType | None] = {}
|
||||
|
||||
conn.set_authorizer(authorizer)
|
||||
try:
|
||||
|
|
@ -523,7 +522,7 @@ def analyze_sql_tables(
|
|||
return True
|
||||
return False
|
||||
|
||||
def table_kind_for(key: OperationKey) -> SQLTableKind | None:
|
||||
def table_kind_for(key: OperationKey) -> SQLiteTableType | None:
|
||||
if (
|
||||
key.target_type != "table"
|
||||
or key.operation not in {"read", "insert", "update", "delete"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue