Skip to content

Commit

Permalink
fixing multiple match predicates query parsing issue (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
slorello89 authored Oct 21, 2024
1 parent 73b528e commit cc3eafb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Redis.OM/Common/ExpressionParserUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ private static string TranslateMethodStandardQuerySyntax(MethodCallExpression ex
return exp.Method.Name switch
{
nameof(StringExtension.FuzzyMatch) => TranslateFuzzyMatch(exp),
nameof(StringExtension.MatchContains) => TranslateMatchContains(exp),
nameof(StringExtension.MatchStartsWith) => TranslateMatchStartsWith(exp),
nameof(StringExtension.MatchEndsWith) => TranslateEndsWith(exp),
nameof(StringExtension.MatchPattern) => TranslateMatchPattern(exp),
nameof(string.Format) => TranslateFormatMethodStandardQuerySyntax(exp),
nameof(string.Contains) => TranslateContainsStandardQuerySyntax(exp, parameters),
nameof(string.StartsWith) => TranslateStartsWith(exp),
Expand Down
17 changes: 17 additions & 0 deletions test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,23 @@ public void TestMatchContains()
"0",
"100");
}

[Fact]
public void TestMultipleMatches()
{
_substitute.ClearSubstitute();
_substitute.Execute(Arg.Any<string>(), Arg.Any<object[]>()).Returns(_mockReply);

var collection = new RedisCollection<Person>(_substitute);
_ = collection.Where(x => x.Name.MatchContains("Ste") && x.Name.MatchStartsWith("Stev") && x.Name.MatchEndsWith("eve") && x.Name.MatchPattern("%Stepe%")).ToList();
_substitute.Received().Execute(
"FT.SEARCH",
"person-idx",
"((((@Name:*Ste*) (@Name:Stev*)) (@Name:*eve)) (@Name:%Stepe%))",
"LIMIT",
"0",
"100");
}

[Fact]
public void TestMatchPattern()
Expand Down

0 comments on commit cc3eafb

Please sign in to comment.