FTS detection treats table names as LIKE patterns

未关闭 适合新手
#930 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

@IlyaKhalafi 已经在做这个了。

开始于 2026年11月6日。

  • #931 来自 @IlyaKhalafi —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, sqlite
领域
database

调研方向

先阅读 detect_fts() 及其用于查找 FTS 表的 LIKE 模式;issue 指出表名通配符处理是原因。用提供的 book_titles 和 bookXtitles 示例重现问题,然后检查是否有回归测试覆盖 _ 和 %。检测到 book_titles_fts,且搜索 incorrect 不返回任何行,即为完成。

由索引模型根据 Issue 内容生成。

描述

When a table name contains _ or %, detect_fts() treats those characters as SQL LIKE wildcards. It can select another table's FTS index and use its matching row IDs against the requested table.

from sqlite_utils import Database

db = Database(memory=True)
db["bookXtitles"].insert({"title": "incorrect"}).enable_fts(["title"])
db["book_titles"].insert({"title": "correct"}).enable_fts(["title"])

print(db["book_titles"].detect_fts())
print(list(db["book_titles"].search("incorrect")))

Current main prints bookXtitles_fts and returns the row containing correct, even though that row does not match the search. It should detect book_titles_fts and return no rows for this query.

The same issue occurs with % in the table name. The table-name portion of the LIKE patterns needs escaping. The quote delimiters added for #434 prevent prefix matches but leave wildcard characters active.

Reproduced on Python 3.12 and SQLite 3.53.1 using current main.

主要语言
Python
星标
2.2k
派生
215
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

simonw/sqlite-utils 的其他 Issue

查看 simonw/sqlite-utils 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。