Skip to content

Commit

Permalink
re-include FTS support to pre 3.27
Browse files Browse the repository at this point in the history
  • Loading branch information
asg017 committed Aug 15, 2024
1 parent 17dfc4e commit 0db9065
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions datasette/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,30 @@ async def hidden_table_names(self):
x[0]
for x in await self.execute(
"""
SELECT name
FROM sqlite_master
WHERE name IN ('sqlite_stat1', 'sqlite_stat2', 'sqlite_stat3', 'sqlite_stat4')
OR substr(name, 1, 1) == '_'
ORDER BY 1
WITH base AS (
SELECT name
FROM sqlite_master
WHERE name IN ('sqlite_stat1', 'sqlite_stat2', 'sqlite_stat3', 'sqlite_stat4')
OR substr(name, 1, 1) == '_'
),
fts_suffixes AS (
select column1 as suffix
from (VALUES ('_data'), ('_idx'), ('_docsize'), ('_content'))
),
fts_names AS (
SELECT name
FROM sqlite_master
WHERE sql LIKE '%VIRTUAL TABLE%USING FTS%'
),
fts_shadow_tables AS (
SELECT
printf('%s%s', fts_tables.name, fts_suffixes.suffix) AS name
FROM fts_names
JOIN fts_suffixes
)
SELECT name FROM base
UNION ALL
SELECT name FROM fts_shadow_tables
"""
)
]
Expand Down

0 comments on commit 0db9065

Please sign in to comment.