Skip to content

Commit

Permalink
fixing backwards contains queries. (#202)
Browse files Browse the repository at this point in the history
* fixing backwards contains queries.

* revving version

Co-authored-by: slorello89 <steve.lorello@redislabs.com>
  • Loading branch information
slorello89 and slorello89 authored Sep 18, 2022
1 parent 684e980 commit 53650de
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/Redis.OM/Common/ExpressionParserUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,13 @@ private static string TranslateContainsStandardQuerySyntax(MethodCallExpression
{
var propertyExpression = (MemberExpression)exp.Arguments.Last();
var valuesExpression = (MemberExpression)exp.Arguments.First();
literal = GetOperandStringForQueryArgs(propertyExpression);
if (!literal.StartsWith("@"))
{
propertyExpression = (MemberExpression)exp.Arguments.First();
valuesExpression = (MemberExpression)exp.Arguments.Last();
}

var attribute = DetermineSearchAttribute(propertyExpression);
if (attribute == null)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Redis.OM/Redis.OM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<RootNamespace>Redis.OM</RootNamespace>
<Nullable>enable</Nullable>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PackageVersion>0.2.2</PackageVersion>
<Version>0.2.2</Version>
<PackageReleaseNotes>https://github.com/redis/redis-om-dotnet/releases/tag/v0.2.2</PackageReleaseNotes>
<PackageVersion>0.2.3</PackageVersion>
<Version>0.2.3</Version>
<PackageReleaseNotes>https://github.com/redis/redis-om-dotnet/releases/tag/v0.2.3</PackageReleaseNotes>
<Description>Object Mapping and More for Redis</Description>
<Title>Redis OM</Title>
<Authors>Steve Lorello</Authors>
Expand Down
21 changes: 20 additions & 1 deletion test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2150,7 +2150,26 @@ public void SearchNumericFieldContains()
"0",
"100"));
}


[Fact]
public void Issue201()
{
_mock.Setup(x => x.Execute(It.IsAny<string>(), It.IsAny<string[]>()))
.Returns(_mockReply);

var p1 = new Person() {Name = "Steve"};
var collection = new RedisCollection<Person>(_mock.Object, 1000);
collection.Where(x=>x.NickNames.Contains(p1.Name)).ToList();

_mock.Verify(x => x.Execute(
"FT.SEARCH",
"person-idx",
"(@NickNames:{Steve})",
"LIMIT",
"0",
"1000"
));
}


}
Expand Down

0 comments on commit 53650de

Please sign in to comment.