File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
test/Redis.OM.Unit.Tests/RediSearchTests Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -833,15 +833,21 @@ private static string TranslateContainsStandardQuerySyntax(MethodCallExpression
833
833
}
834
834
835
835
type = Nullable . GetUnderlyingType ( propertyExpression . Type ) ?? propertyExpression . Type ;
836
+ var valueType = Nullable . GetUnderlyingType ( valuesExpression . Type ) ?? valuesExpression . Type ;
836
837
memberName = GetOperandStringForMember ( propertyExpression ) ;
837
838
var treatEnumsAsInts = type . IsEnum && ! ( propertyExpression . Member . GetCustomAttributes ( typeof ( JsonConverterAttribute ) ) . FirstOrDefault ( ) is JsonConverterAttribute converter && converter . ConverterType == typeof ( JsonStringEnumConverter ) ) ;
838
839
literal = GetOperandStringForQueryArgs ( valuesExpression , treatEnumsAsInts ) ;
839
840
840
- if ( ( type == typeof ( string ) || type == typeof ( string [ ] ) || type == typeof ( List < string > ) || type == typeof ( Guid ) || type == typeof ( Guid [ ] ) || type == typeof ( List < Guid > ) || type == typeof ( Ulid ) || ( type . IsEnum && ! treatEnumsAsInts ) ) && attribute is IndexedAttribute )
841
+ if ( ( valueType == typeof ( List < string > ) || valueType == typeof ( string [ ] ) || type == typeof ( string [ ] ) || type == typeof ( List < string > ) || type == typeof ( Guid ) || type == typeof ( Guid [ ] ) || type == typeof ( List < Guid > ) || type == typeof ( Guid [ ] ) || type == typeof ( List < Guid > ) || type == typeof ( Ulid ) || ( type . IsEnum && ! treatEnumsAsInts ) ) && attribute is IndexedAttribute )
841
842
{
842
843
return $ "({ memberName } :{{{EscapeTagField(literal).Replace("\\ | ", " | ")}}})" ;
843
844
}
844
845
846
+ if ( type == typeof ( string ) && attribute is IndexedAttribute )
847
+ {
848
+ return $ "({ memberName } :{{*{ EscapeTagField ( literal ) } *}})";
849
+ }
850
+
845
851
if ( type == typeof ( string ) && attribute is SearchableAttribute )
846
852
{
847
853
return $ "({ memberName } :{ literal } )";
Original file line number Diff line number Diff line change @@ -372,7 +372,7 @@ public void TestMatchEndsWith()
372
372
"0" ,
373
373
"100" ) ;
374
374
}
375
-
375
+
376
376
[ Fact ]
377
377
public void TestMatchContains ( )
378
378
{
@@ -390,6 +390,34 @@ public void TestMatchContains()
390
390
"100" ) ;
391
391
}
392
392
393
+ [ Fact ]
394
+ public void TestTagContains ( )
395
+ {
396
+ _substitute . ClearSubstitute ( ) ;
397
+ _substitute . Execute ( Arg . Any < string > ( ) , Arg . Any < string [ ] > ( ) ) . Returns ( _mockReply ) ;
398
+
399
+ var ste = "Ste" ;
400
+ var person = new Person ( ) { TagField = "ath" } ;
401
+ var collection = new RedisCollection < Person > ( _substitute ) ;
402
+ _ = collection . Where ( x => x . TagField . Contains ( ste ) ) . ToList ( ) ;
403
+ _ = collection . Where ( x => x . TagField . Contains ( person . TagField ) ) . ToList ( ) ;
404
+ _substitute . Received ( ) . Execute (
405
+ "FT.SEARCH" ,
406
+ "person-idx" ,
407
+ "(@TagField:{*Ste*})" ,
408
+ "LIMIT" ,
409
+ "0" ,
410
+ "100" ) ;
411
+
412
+ _substitute . Received ( ) . Execute (
413
+ "FT.SEARCH" ,
414
+ "person-idx" ,
415
+ "(@TagField:{*ath*})" ,
416
+ "LIMIT" ,
417
+ "0" ,
418
+ "100" ) ;
419
+ }
420
+
393
421
[ Fact ]
394
422
public void TestTagStartsWith ( )
395
423
{
You can’t perform that action at this time.
0 commit comments