enable_fts() exhausts iterator columns before populating the index

オープン 初心者向け
#902 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@syahra712 がすでに取り組んでいます。

2026年10月11日 から。

  • #903 @syahra712 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
83/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, sqlite
領域
databases

調査の方向性

トリガーの構築を含め、Table.enable_fts() と populate_fts() の実装を読み、その後、インメモリデータベースで issue の再現手順を実行してください。columns イテラブルが、FTS テーブルの作成とデータ投入、およびトリガーの構築にどのように使われるかを確認してください。FTS4 と FTS5 の両方で、トリガーの有無にかかわらず一度しか反復できないイテレーターが機能し、リスト入力も引き続き機能すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Problem

Table.enable_fts() accepts columns: Iterable[str], but passing a one-shot iterator raises sqlite3.OperationalError: near ")": syntax error. The same columns supplied as a list work. The FTS virtual table has already been created when the error occurs, so a retry without replace=True also encounters an existing table.

Reproduced locally against main 9c66bafa52ae23d40499c74b0db3b635bcddb876, Python 3.12.14, using an in-memory database:

from sqlite_utils import Database

db = Database(memory=True)
table = db["notes"].insert({"text": "hello"})
table.enable_fts(iter(["text"]))
# sqlite3.OperationalError: near ")": syntax error

Replacing iter(["text"]) with ["text"] succeeds and list(table.search("hello")) returns the record. I reproduced the failure with both FTS4 and FTS5, with and without create_triggers=True.

The iterable is consumed while building CREATE VIRTUAL TABLE, then passed to populate_fts(). Trigger construction also reuses it. Materializing the columns once would preserve the declared iterable contract.

AI assistance: OpenAI Codex inspected the code and ran this reproduction. No live service, user database, or external model call was used.

主要言語
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 を短くまとめたダイジェスト。