Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions QueryKit.UnitTests/FilterParsingRegressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,26 +248,6 @@ public void comparison_operator_factory_has_one_test_case_per_operator_type()
ComparisonOperatorFactories().Should().HaveCount(24);
}

[Theory]
[InlineData(false, new[] { "lamb" })]
[InlineData(true, new[] { "null", "other" })]
public void case_insensitive_in_operator_factory_reads_a_constant_list(bool notIn, string[] expectedFirstNames)
{
var people = new[]
{
new TestingPerson { Title = null, FirstName = "null" },
new TestingPerson { Title = "Lamb", FirstName = "lamb" },
new TestingPerson { Title = "other", FirstName = "other" },
};
Expression<Func<TestingPerson, string?>> title = x => x.Title;
var comparisonOperator = notIn ? ComparisonOperator.NotInOperator(true) : ComparisonOperator.InOperator(true);

var body = comparisonOperator.GetExpression<TestingPerson>(title.Body, Expression.Constant(new List<string> { "LAMB" }), null);
var filterExpression = Expression.Lambda<Func<TestingPerson, bool>>(body, title.Parameters);

people.AsQueryable().Where(filterExpression).Select(x => x.FirstName).Should().Equal(expectedFirstNames);
}

[Fact]
public void comparison_operator_factory_with_uses_all_builds_any_expression()
{
Expand Down
6 changes: 2 additions & 4 deletions QueryKit/Operators/ComparisonOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ public override Expression GetExpression<T>(Expression left, Expression right, T
var listType = typeof(List<string>);
var caseList = Activator.CreateInstance(listType);

// A caller can pass the list as a constant, like v1.14.2.
var originalList = (values ?? ((ConstantExpression)right).Value) as IEnumerable<string>;
var originalList = values as IEnumerable<string>;
foreach (var value in originalList!)
{
listType.GetMethod("Add")!.Invoke(caseList, new[] { caseMode == CaseInsensitiveMode.Upper ? value.ToUpper() : value.ToLower() });
Expand Down Expand Up @@ -834,8 +833,7 @@ public override Expression GetExpression<T>(Expression left, Expression right, T
var listType = typeof(List<string>);
var caseList = Activator.CreateInstance(listType);

// A caller can pass the list as a constant, like v1.14.2.
var originalList = (values ?? ((ConstantExpression)right).Value) as IEnumerable<string>;
var originalList = values as IEnumerable<string>;
foreach (var value in originalList!)
{
listType.GetMethod("Add")!.Invoke(caseList, new[] { caseMode == CaseInsensitiveMode.Upper ? value.ToUpper() : value.ToLower() });
Expand Down
Loading