Repository navigation
fix(filter): support the in operator on a collection and reject one value - #207
Merged
Merged
Conversation
…alue The in operators (^^ and !^^) threw a .NET exception for one value instead of a list: ArgumentException, or NullReferenceException for ^^*. They also failed on a collection property and on a nested path such as Ingredients.Name. - One value now throws QueryKitParsingException: "The ^^ operator needs a list value, for example ["a", "b"]." - On a collection, ^^ matches when any element is in the list, and %^^ when all elements are in the list. !^^ is the negation of ^^: no element is in the list. Fixes #204 Fixes #202
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #204
Fixes #202
Problem
Title ^^ "Pancakes"ArgumentExceptionwith .NET type names in the messageTitle ^^* "pancakes"NullReferenceExceptionRating ^^ 5,Visibility ^^ "Public"ArgumentExceptionTags ^^ ["dinner", "sweet"]ArgumentExceptionIngredients.Name ^^ ["salt"]ArgumentExceptionChange
InTypeandNotInTypethrowQueryKitParsingExceptionwhen the right side is not a list: "The ^^ operator needs a list value, for example ["a", "b"]." The message names the operator that the caller sent (^^,!^^,^^*, or!^^*).^^matches when any element is in the list, and%^^matches when all elements are in the list. The element comparison reuses the scalar in path, so case-insensitive^^*and theInListValuesparameter work the same as on a scalar property.!^^is the negation of^^: no element is in the list. This is what Support the in operator (^^) on a collection property #202 asked for. It is different from!=, which matches when any element is different.Behavior change: the in operators with one value throw
QueryKitParsingExceptioninstead ofArgumentExceptionorNullReferenceException.Tests
QueryKit.UnitTests/InOperatorTests.cs: one value on a string, a number, an enum, a Guid, and a collection, with each operator form. Lists on a scalar property as guards.^^,!^^,%^^,^^*, and!^^*onList<T>,IReadOnlyList<T>,HashSet<T>, arrays, and a nested path. A number collection. Before the fix, 35 of 39 cases failed.QueryKit.IntegrationTests/Tests/CollectionTypeFilterTests.cs: the in forms on a projected DTO on Postgres, a nested path through theIngredientsnavigation, and the one-value error.Tags ^^ [...]isEXISTS (SELECT 1 FROM unnest(r."Tags") AS t(value) WHERE t.value IN ('dinner', 'sweet')).Also fixes two old nullable warnings in
QueryKit.IntegrationTests/Tests/HasConversionTests.cs.