Support 'Match...' of string and IEnumerable<string>#551
Merged
Conversation
…y from Redis and Memory.
- Fix two unit tests that asserted nothing: TestMatchStartsWithOfString and TestMatchStartsWithOfStringArray called _substitute.Execute(...) instead of _substitute.Received().Execute(...), so the generated query was never verified. - Remove leftover junk (the `ddfgdf` locals) and dead trailing lines in the Match* substitute tests. - Add functional (real-Redis) tests for the string overloads of MatchStartsWith, MatchEndsWith, and MatchContains (previously only MatchPattern had functional coverage), and for all four IEnumerable<string>/tag overloads, exercising the brace tag-query syntax end-to-end. The shared seed helper clears people first and each test clears again in a finally block so it stays order-independent and does not pollute the shared Person collection used by other tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 0ea08df. Configure here.
Per Cursor Bugbot: the tag-field paths of TranslateMatchStartsWith,
TranslateMatchEndsWith, and TranslateMatchContains emitted the prefix/suffix/
infix literal raw, unlike peer translators (TranslateStartsWith/EndsWith, tag
Contains) which wrap the literal in EscapeTagField. Special characters in the
search term (e.g. '-', '@', spaces) could therefore produce malformed or
unintended tag queries on indexed string-array fields like NickNames.
Wrap the literal with EscapeTagField in those three tag paths while keeping the
wildcard operators outside the escaped portion. MatchPattern is intentionally
left raw since its argument is a user-supplied wildcard pattern.
Add unit tests asserting the escaped query output and a functional test proving
a hyphenated tag value ("Spider-Man") matches end-to-end. Also make the new
functional Match* tests non-destructive: they insert uniquely-named records and
delete only those in a finally block, so they don't disturb the shared Person
collection other tests rely on.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Add
for support
IEnumerable<string>.Note
Medium Risk
Changes query translation for Match* methods and fixes prior incorrect Contains/Pattern shadow behavior, which can alter search results for tag fields and in-memory eval paths; risk is mitigated by broad new tests.
Overview
Extends
MatchStartsWith,MatchEndsWith,MatchContains, andMatchPatternso they work onIEnumerable<string>(tag-indexed fields likeNickNames) in LINQ queries, not only on full-textstringfields.Expression translation (
ExpressionParserUtilities) now branches on the receiver type: text fields keep the existing wildcard query shape; tag fields emit RediSearch tag syntax ({...}) withEscapeTagFieldon literals while preserving wildcards, including a case for hyphenated tags (e.g.Spider-Man).In-process “shadow” implementations (
StringExtension) add matchingIEnumerable<string>overloads, fixMatchContains/MatchPatternonstring(they incorrectly usedEndsWith), use case-insensitive token checks, and implementMatchPatternvia aWildcardToRegexhelper aligned with Redis wildcard rules.Coverage adds unit tests that assert generated
FT.SEARCHquery strings (including tag escaping) and functional Redis tests for text and tagMatch*predicates.Reviewed by Cursor Bugbot for commit 69fc325. Bugbot is set up for automated code reviews on this repo. Configure here.