pdevito3 / QueryKit

🎛️ QueryKit is a .NET library that makes it easier to query your data by providing a fluent and intuitive syntax for filtering and sorting.
Apache License 2.0
147 stars 13 forks source link

fix: fixing issue #19: Configuration throwing exception related to No… #20

Closed AlexMKotcz closed 7 months ago

AlexMKotcz commented 7 months ago

After some inspecting, I was able to completely solve the exception for my example provided on issue #19. This PR was the result.

The behavior before

On ParseFilter, called ReplaceComparisonAliases, then called GetAliasMatches. On GetAliasMatches, in this line:

        if(aliases.NotInOperator != NotInOperator().Operator())
        {
            matches.Add(new ComparisonAliasMatch { Alias = aliases.NotInOperator, Operator = NotInOperator().Operator() });
            matches.Add(new ComparisonAliasMatch { Alias = $"{aliases.NotInOperator}{caseInsensitiveAppendix}", Operator = $"{NotInOperator(true).Operator()}" });
        }

It added to matches even when not specifying an alias for NotInOperator, because aliases.NotInOperator was null.

Then, in the ReplaceComparisonAliases method, line var escapedAlias = Regex.Escape(comparisonAliasMatch.Alias); throws the exception.

The behavior now

As the NotInOperator is now assigned and not null, the condition on the if is not true (because I didn't provide a custom alias). Now, the foreach doesn't throws an exception.

Tests

Before tests-before After tests-after

pdevito3 commented 7 months ago

whoops, thanks for this! if you change this to target main, i'll merge it in and do a patch release. I want you to get contribution credit this time!

annoying because i need a develop or equivalent working branch for active and working doc separation, but then stuff normal PRs that i can't always merge in to a release right away won't get contribution... need to look into the right way to do this i'm sure i'm missing something simple.

either way. appreciate the assit and want to make sure you get credit this time!

AlexMKotcz commented 7 months ago

Sure! Just did! Thanks!