You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Table.indexes / xindexes fail with OperationalError when identifiers contain double quotes (breaks transform()) #824
Table.indexes and Table.xindexes build their PRAGMA statements with naive f-string quoting instead of quote_identifier(), so any identifier containing a double quote produces malformed SQL:
indexes / xindexes: sql = f'PRAGMA index_list("{self.name}")' — embedded " in the table name is never doubled
both properties then wrap the index name with an ad-hoc heuristic (f'"{index_name}"' if not index_name.startswith('"') else index_name) that has the same flaw
This looks like a missed spot in the #678 migration (fb93452, "Use double quotes not braces for tables and columns"): quote_identifier() is used 103 times in the same file, including the neighbouring PRAGMA table_info and PRAGMA foreign_key_list, but these four sites kept the old quoting.
It cascades beyond introspection because self.indexes is consumed by transform(), drop_index() and Database.create, so transform() raises OperationalError for any table whose name contains a " — or any table carrying an index on a column whose name contains one. Column names like that routinely arrive from CSV/JSON headers.
Related (same family, different method, can file separately if useful): detect_fts() interpolates content="{self.name}" into its like2 pattern without doubling embedded quotes, so search() reports "Full-text search is not configured" immediately after a successful enable_fts() on such a table.
I have a fix ready (replace the four sites with quote_identifier(), net −6 lines, plus two regression tests) and will open a PR referencing this issue.
I've verified this against the current main and put together the fix. quote_identifier() is already defined at line 79 of db.py and used 103 times in the same file — the four PRAGMA sites in indexes / xindexes just missed it.
Activity
ikatyal2110 commentedon Aug 11, 2026
I've verified this against the current
mainand put together the fix.quote_identifier()is already defined at line 79 ofdb.pyand used 103 times in the same file — the four PRAGMA sites inindexes/xindexesjust missed it.The diff is minimal:
Repro that fails before and passes after:
Happy to open a PR if that would help.
Generated by Claude Code
Use quote_identifier() in indexes/xindexes PRAGMA statements (simonw#825
Changelog updates
Release 4.2