From 0bdcdcc82f784d2d987c4fff6bd7fb2edcb1d75f Mon Sep 17 00:00:00 2001 From: Alex Garcia Date: Thu, 15 Aug 2024 11:55:06 -0700 Subject: [PATCH] =?UTF-8?q?fts3/fts4=20support=20=F0=9F=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- datasette/database.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/datasette/database.py b/datasette/database.py index f811b95eed..8d51befda7 100644 --- a/datasette/database.py +++ b/datasette/database.py @@ -509,21 +509,39 @@ async def hidden_table_names(self): SELECT column1 AS suffix FROM (VALUES ('_data'), ('_idx'), ('_docsize'), ('_content'), ('_config')) ), - fts_names AS ( + fts5_names AS ( SELECT name FROM sqlite_master WHERE sql LIKE '%VIRTUAL TABLE%USING FTS%' ), - fts_shadow_tables AS ( + fts5_shadow_tables AS ( SELECT - printf('%s%s', fts_names.name, fts_suffixes.suffix) AS name - FROM fts_names + printf('%s%s', fts5_names.name, fts_suffixes.suffix) AS name + FROM fts5_names JOIN fts_suffixes ), + fts3_suffixes AS ( + SELECT column1 AS suffix + FROM (VALUES ('_content'), ('_segdir'), ('_segments'), ('_stat'), ('_docsize')) + ), + fts3_names AS ( + SELECT name + FROM sqlite_master + WHERE sql LIKE '%VIRTUAL TABLE%USING FTS3%' + OR sql LIKE '%VIRTUAL TABLE%USING FTS4%' + ), + fts3_shadow_tables AS ( + SELECT + printf('%s%s', fts3_names.name, fts3_suffixes.suffix) AS name + FROM fts3_names + JOIN fts3_suffixes + ), final AS ( SELECT name FROM base UNION ALL - SELECT name FROM fts_shadow_tables + SELECT name FROM fts5_shadow_tables + UNION ALL + SELECT name FROM fts3_shadow_tables ) SELECT name FROM final ORDER BY 1