fix: sanitize hyphenated session-search FTS queries - #7820
Closed
samwei12 wants to merge 1 commit into
Closed
Conversation
- collapse duplicated boolean operators during FTS query sanitization - quote hyphenated terms like wrong-book so broad OR queries remain executable - add regression coverage for the reported session search query path
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.
Summary
Fix a session-search FTS edge case where a broad OR query can fail if one of the search terms is hyphenated.
Linked issue
Closes #7824
Problem
A query such as:
错题本 OR 错题 OR wrong-book OR mistakescan fail in SQLite FTS5 with:
sqlite3.OperationalError: no such column: bookbecause a bare hyphenated token like
wrong-bookmay be interpreted as a column-filter expression instead of a normal term.Fix
Keep the change narrow in the FTS sanitization path:
Why this scope
This PR intentionally stays at the query sanitization layer and adds only regression coverage for the reported failure mode. It does not add tool-layer retry/fallback behavior or unrelated search semantics changes.
Verification
pytest -q tests/test_hermes_state.py::TestFTS5Search