From 0a3a3c503afeda279b3d8ebc07c00258b5b5b2b4 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Thu, 9 Jun 2022 14:03:47 -0700 Subject: [PATCH] revert changes to sqlite describe --- src/sqlite.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sqlite.js b/src/sqlite.js index 68f662a3..709f9ed9 100644 --- a/src/sqlite.js +++ b/src/sqlite.js @@ -37,8 +37,11 @@ export class SQLiteDatabaseClient { if (!rows.length) throw new Error(`table not found: ${table}`); return rows.map(({name, type, notnull}) => ({name, type: sqliteType(type), databaseType: type, nullable: !notnull})); } - async describe(table) { - const rows = await (table === undefined ? this.describeTables() : this.describeColumns({table})); + async describe(object) { + const rows = await (object === undefined + ? this.query(`SELECT name FROM sqlite_master WHERE type = 'table'`) + : this.query(`SELECT * FROM pragma_table_info(?)`, [object])); + if (!rows.length) throw new Error("Not found"); const {columns} = rows; return element("table", {value: rows}, [ element("thead", [element("tr", columns.map(c => element("th", [text(c)])))]),