fix(db): ノート編集時に FTS 索引が旧テキストのまま残るバグを修正#33
Merged
Conversation
notes_cache の upsert が text 列を更新せず、FTS に AFTER UPDATE トリガも なかったため、編集されたノートはローカル検索で取りこぼされていた (notedeck-dev/notedeck#783 の調査で発覚)。 - upsert の DO UPDATE SET に text = excluded.text を追加 - V4 migration: AFTER UPDATE OF text トリガを追加。FTS 側にエントリが ない行への 'delete' は database corrupt になるため、INSERT ... SELECT ... WHERE で NULL text をガードした単一トリガにする(2 トリガ分割は 発火順が未定義) - 既存 DB の text / note_json 乖離を migration 内で修復(トリガ経由で FTS も追随) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
なぜ
notedeck-dev/notedeck#783 の調査で発覚した既存バグ。
notes_cacheの upsert がtext列を更新せず、FTS にAFTER UPDATEトリガもないため、編集されたノートはローカル検索で旧テキストのままヒットし続け、新テキストでは取りこぼされる。変更
DO UPDATE SETにtext = excluded.textを追加AFTER UPDATE OF textトリガを追加'delete'は database corrupt になるため、INSERT ... SELECT ... WHEREで条件付き実行にした単一トリガ(2 トリガ分割は発火順が未定義)text/note_json乖離を migration 内で修復(トリガ経由で FTS も追随)テスト
fts_search_reflects_note_edit: 編集後テキストでヒット・編集前テキストの索引が残らないfts_search_reflects_edit_from_null_text: text NULL → テキスト付きへの再キャッシュ(corrupt 回帰の検出)🤖 Generated with Claude Code