Skip to content

Detect FTS tables with unquoted or single-quoted content= - #3011

Merged
simonw merged 1 commit into
simonw:mainfrom
b84330808:detect-fts-unquoted-content
Nov 8, 2026
Merged

simonw merged 1 commit into
simonw:mainfrom
b84330808:detect-fts-unquoted-content

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Closes #1991

detect_fts() only recognised FTS tables declared with content="table" or content=[table]. SQLite also accepts content=table (the form used in the FTS5 docs), content='table' and content=`table` . With any of those, the table page shows no search box and ?_search= is silently ignored, so it returns every row.

The hiding half of #1991 is already fixed on main, because sqlite_hidden_table_names() now parses the DDL. This handles the detection half. When the existing LIKE query finds nothing, detect_fts() parses the content= option with _fts_external_content_table(), the same helper the derived-table permission code uses. An instr() check limits the parsing to FTS declarations that mention the table name, so the extra cost stays small on databases with many tables.

I added the three quoting styles to the existing test_detect_fts parametrization, plus a check that a table whose name is a prefix of the content table (Street_Tree vs Street_Tree_List) isn't matched.

I used Claude Code to write this change.

…onw#1991

detect_fts() only matched content="table" and content=[table], so an FTS
table created with content=captions (the form used in the SQLite FTS5
docs), content='captions' or content=`captions` was not detected: the
table page had no search box and ?_search= was silently ignored.

When the existing LIKE query finds nothing, fall back to parsing the
content= option with _fts_external_content_table(), the same helper the
derived table permission code already uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@simonw
simonw merged commit 910d47c into simonw:main Nov 8, 2026
12 of 13 checks passed
@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (c435a80) to head (b8c201a).
⚠️ Report is 101 commits behind head on main.

Files with missing lines Patch % Lines
datasette/utils/__init__.py 0.00% 8 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3011   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         78      78           
  Lines      13371   13376    +5     
=====================================
- Misses     13371   13376    +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fts5 tables are not auto-detected and hidden

2 participants