Skip to content

Commit

Permalink
made contains case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamess-Lucass committed Nov 4, 2024
1 parent 444f8c0 commit da83265
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/GoatQuery/src/Evaluator/FilterEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public static Result<Expression> Evaluate(QueryExpression expression, ParameterE
case Keywords.Contains:
var identifier = (Identifier)exp.Left;

var method = identifier.Value.GetType().GetMethod("Contains", new[] { value?.Value.GetType() });
var method = identifier.Value.GetType().GetMethod("Contains", new[] { value?.Value.GetType(), typeof(StringComparison) });

return Expression.Call(property, method, value);
return Expression.Call(property, method, value, Expression.Constant(StringComparison.OrdinalIgnoreCase));
case Keywords.Lt:
return Expression.LessThan(property, value);
case Keywords.Lte:
Expand Down
4 changes: 2 additions & 2 deletions src/GoatQuery/tests/Filter/FilterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public static IEnumerable<object[]> Parameters()

yield return new object[] {
"firstName contains 'a'",
new[] { _users["Jane"], _users["Harry"] }
new[] { _users["Jane"], _users["Apple"], _users["Harry"] }
};

yield return new object[] {
"Age ne 1 and firstName contains 'a'",
Array.Empty<User>()
new[] { _users["Apple"] }
};

yield return new object[] {
Expand Down
2 changes: 1 addition & 1 deletion src/GoatQuery/tests/Top/TopTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void Test_TopWithMaxTop(int top, int expectedCount)
[InlineData(5)]
[InlineData(100)]
[InlineData(100_000)]
public void Test_TopWithMaxTopThrowsException(int top)
public void Test_TopWithMaxTopReturnsError(int top)
{
var users = new List<User>{
new User { Age = 1, Firstname = "Jane" },
Expand Down

0 comments on commit da83265

Please sign in to comment.