Skip to content

Fix FTS4 triggers for updates and deletes - #923

Open
Muguett-DBY wants to merge 3 commits into
simonw:mainfrom
Muguett-DBY:fix/fts4-external-content-triggers
Open

Muguett-DBY wants to merge 3 commits into
simonw:mainfrom
Muguett-DBY:fix/fts4-external-content-triggers

Conversation

@Muguett-DBY

@Muguett-DBY Muguett-DBY commented Oct 29, 2026 •

Copy link
Copy Markdown

Fixes #922.

FTS4 needs the old content row to be available when it removes an index entry. This uses BEFORE DELETE and BEFORE UPDATE triggers for that removal, followed by an AFTER UPDATE trigger to index the new values. The existing FTS5 triggers are unchanged.

replace=True recreates older FTS4 trigger sets, and disable_fts() now also removes DELETE-based triggers while handling quoted names and SQL wildcard characters safely.

Testing:

  • The full pytest suite passed on Windows, Python 3.12.14 and SQLite 3.53.1 with UTF-8 mode enabled: 1,505 passed, 17 skipped, 32 warnings.
  • Black 26.3.1 passed for the three changed files.
  • mypy sqlite_utils tests passed with the project configuration (mypy 2.4.1).
  • The repository-wide flake8 check passed (flake8 7.5.0).
  • Restoring the original FTS methods caused seven of 56 selected tests to fail (the five filesystem-fixture tests were not included in that comparison).

I used Codex to help investigate and implement this fix, and reviewed the changes and test results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FTS4 triggers fail when indexed rows are updated or deleted

1 participant