fix: escape SQL LIKE wildcards in semantic memory search#208
Open
haosenwang1018 wants to merge 1 commit intoConway-Research:mainfrom
Open
fix: escape SQL LIKE wildcards in semantic memory search#208haosenwang1018 wants to merge 1 commit intoConway-Research:mainfrom
haosenwang1018 wants to merge 1 commit intoConway-Research:mainfrom
Conversation
SemanticMemoryManager.search() interpolates the query directly into LIKE patterns without escaping '%' and '_'. A search for "100%" would match any value starting with "100" followed by anything, and "_" would match any single character instead of a literal underscore. This was fixed for episodic and procedural memory in PR Conway-Research#127 but the same fix was not applied to semantic memory. Apply the identical escaping pattern: replace '%' and '_' with their backslash-escaped forms and add ESCAPE '\\' to both LIKE clauses. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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
SemanticMemoryManager.search()interpolates the query directly into LIKE patterns (%${query}%) without escaping SQL wildcards"100%"matches any value starting with"100"followed by anything;"_"matches any single characterFix
%and_in the query usingquery.replace(/[%_]/g, (ch) => '\\' + ch)ESCAPE '\\'to both LIKE clauses (with-category and without-category paths)Test plan
npx tsc --noEmitpasses%or_and verify exact match behavior