diff --git a/src/Gridify/Syntax/Parser.cs b/src/Gridify/Syntax/Parser.cs index 4eb6fd8..8892c2e 100644 --- a/src/Gridify/Syntax/Parser.cs +++ b/src/Gridify/Syntax/Parser.cs @@ -107,7 +107,12 @@ private ValueExpressionSyntax ParseValueExpression() { // field= if (Current.Kind != SyntaxKind.ValueToken) - return new ValueExpressionSyntax(new SyntaxToken(), false, true); + { + if (Current.Kind != SyntaxKind.CaseInsensitive) return new ValueExpressionSyntax(new SyntaxToken(), false, true); + NextToken(); // field=/i + return new ValueExpressionSyntax(new SyntaxToken(), true, true); + } + var valueToken = Match(SyntaxKind.ValueToken); var isCaseInsensitive = TryMatch(SyntaxKind.CaseInsensitive, out _); diff --git a/test/Gridify.Tests/IssueTests/Issue171Tests.cs b/test/Gridify.Tests/IssueTests/Issue171Tests.cs index 1f0c388..863cf11 100644 --- a/test/Gridify.Tests/IssueTests/Issue171Tests.cs +++ b/test/Gridify.Tests/IssueTests/Issue171Tests.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Xunit; @@ -7,7 +7,18 @@ namespace Gridify.Tests.IssueTests; public class Issue171Tests { - private readonly List _fakeRepository = [..GridifyExtensionsShould.GetSampleData(), new TestClass(4444,"/i",null)]; + private readonly List _fakeRepository = [.. GridifyExtensionsShould.GetSampleData(), new TestClass(4444, "/i", null)]; + + [Fact] + public void ApplyFiltering_CaseInsensitiveEmptyFieldsWithParenthesis_ShouldFilter() + { + var actual = _fakeRepository.AsQueryable().ApplyFiltering("(tag=/i)").ToList(); + var expected = _fakeRepository.Where(q => string.IsNullOrEmpty(q.Tag)).ToList(); + + Assert.Equal(expected.Count, actual.Count); + Assert.Equal(expected, actual); + Assert.True(actual.Any()); + } [Fact] public void ApplyFiltering_CaseInsensitiveEmptyFields_ShouldFilter()