Repository navigation
fix(core): quote punctuated words one by one in SQLite full-text queries - #1695
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c7a306a28
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
0edc2f8 to
e375b28
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e375b283ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A multi-word query where any word carried FTS5-significant punctuation (IT-644, #344, --diff, config.json) was quoted whole, as one exact phrase. A phrase needs its words adjacent and in order, so "IT-644 cacheability" returned nothing although both words are in the note (#1657). Each punctuated word is now quoted as its own phrase and every word is AND-joined, so order and distance do not matter. A phrase the caller quoted stays one unit, a single caller-quoted term is not quoted twice, a file path keeps its exact match, and a word with no letters or digits ("&") is dropped: it has no tokens in the index, and as an empty phrase it would make the AND match nothing. Ported from @dougvann's fix (d498fed on his fork) onto the current query module, with his test cases. Co-authored-by: doug vann <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01APFUk2bjEwMptMQqpRhjea Signed-off-by: phernandez <[email protected]>
…uery `IT-644 cache*` became `"IT-644"* AND cache**`, which FTS5 rejects with a syntax error. A word's own trailing `*` is now stripped before quoting and added back once, so `cache*` stays `cache*` and `IT-6*` becomes `"IT-6"*`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01APFUk2bjEwMptMQqpRhjea Signed-off-by: phernandez <[email protected]>
`IT-644 *cache` became `"IT-644"* AND *cache*`, and FTS5 rejects the bare leading `*`, so the search returned nothing. A `*` left anywhere but the end of a word now makes the word a quoted phrase, which the tokenizer reads as `cache`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01APFUk2bjEwMptMQqpRhjea Signed-off-by: phernandez <[email protected]>
037fc17 to
6cea5d8
Compare
Postgres turned every `*` in a term into `:*` before splitting words, so `foo cache*` became `foo cache:*`: two operands with no `&`, which to_tsquery rejects, and the search returned nothing. Only a single token is converted whole now; in a multi-word query each word handles its own wildcard (a trailing `*` makes it a prefix term, any other `*` is dropped) and the words join with `&`. CI caught this through the new end-to-end `IT-644 cache*` check, which runs on both backends. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01APFUk2bjEwMptMQqpRhjea Signed-off-by: phernandez <[email protected]>
Fixes #1657. Ported from @dougvann's fix (d498fed on his fork). His commit had no DCO sign-off and targets the pre-refactor module, so I ported it onto
sqlite_search_query.pyand credited him withCo-authored-by.Why
In a multi-word query, one word with FTS5-significant punctuation (
IT-644,#344,--diff,config.json) madeprepare_single_termquote the whole query as one exact phrase. A phrase only matches adjacent words in order, soIT-644 cacheabilityreturned nothing although both words are in the note.The title of #1657 points at the
content_stemscap, but that isn't what hid the matches. On SQLite, queries also matchcontent_snippet, which holds the full body (since 5e4b119). On Postgres, the full body is indexed in chunks since #1373. I confirmed live that a token 57 KB into a note is found.Change
"IT-644"* AND cacheability*.&) is dropped. It has no tokens in the index, and as an empty phrase it would make the AND match nothing.test_search_special_characters_in_titlecaught this withNote & Symbols!.Tests
IT-644,#344 #336,--diff,queue:run, caller-quoted phrases), plus the file-path and&cases.IT-644 cacheability.just fast-checkis clean.just fast-teston every test module that touches term preparation, the search service, the search tool, and the search integration tests: 265 passed, 31 skipped (Postgres-only).IT-644 cacheabilitynow hits. Before, it missed.🤖 Generated with Claude Code
https://claude.ai/code/session_01APFUk2bjEwMptMQqpRhjea