FTS detection treats table names as LIKE patterns

オープン 初心者向け
#930 コメント 0 件 リアクション 0 件 担当者 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 はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

simonw/sqlite-utils のほかの issue

simonw/sqlite-utils の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。