Skip to content

store-sqlite: treat substring queries as literals#2

Merged
lsj5031 merged 1 commit intomasterfrom
chore/stability-pass-20260223
Feb 23, 2026
Merged

store-sqlite: treat substring queries as literals#2
lsj5031 merged 1 commit intomasterfrom
chore/stability-pass-20260223

Conversation

@lsj5031
Copy link
Owner

@lsj5031 lsj5031 commented Feb 23, 2026

context/problem

search_substring() builds a SQL LIKE pattern directly from user text. Queries containing _ or % are interpreted as wildcards, so literal searches (for example hello_world) can match unrelated messages (like helloxworld). This makes fallback search results noisy and unpredictable.

exact change

  • Added escape_like_pattern() in crates/store-sqlite/src/lib.rs to escape %, _, and \ in user queries.
  • Updated search_substring() to use the escaped pattern and ESCAPE '\\' in SQL.
  • Added regression test substring_search_escapes_like_wildcards to verify hello_world matches literal underscore content only.

validation steps

  • cargo fmt --all --check
  • cargo test -p store-sqlite
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

All commands passed locally.

rollback notes

Revert commit 3122ce2 to restore previous behavior where % and _ act as SQL wildcards in substring fallback search.

@lsj5031 lsj5031 merged commit 0b157ee into master Feb 23, 2026
2 checks passed
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.

1 participant