Skip to content

fix(filter): support the in operator on a collection and reject one value - #207

Merged
pdevito3 merged 1 commit into
mainfrom
fix/in-operator
Oct 19, 2026
Merged

pdevito3 merged 1 commit into
mainfrom
fix/in-operator

Conversation

@pdevito3

Copy link
Copy Markdown
Owner

Fixes #204
Fixes #202

Problem

Filter Before
Title ^^ "Pancakes" ArgumentException with .NET type names in the message
Title ^^* "pancakes" NullReferenceException
Rating ^^ 5, Visibility ^^ "Public" ArgumentException
Tags ^^ ["dinner", "sweet"] ArgumentException
Ingredients.Name ^^ ["salt"] ArgumentException

Change

  • InType and NotInType throw QueryKitParsingException when 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 !^^*).
  • On a collection, ^^ 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 the InListValues parameter work the same as on a scalar property.
  • On a collection, !^^ 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 QueryKitParsingException instead of ArgumentException or NullReferenceException.

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 !^^* on List<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 the Ingredients navigation, and the one-value error.
  • verify-querykit harness: 12 filters gave the same result on both targets. The Postgres SQL for Tags ^^ [...] is EXISTS (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.

…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
@pdevito3
pdevito3 merged commit 80c1509 into main Oct 19, 2026
2 checks passed
@pdevito3
pdevito3 deleted the fix/in-operator branch October 19, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The ^^ operator on a scalar property throws ArgumentException, not a parsing exception Support the in operator (^^) on a collection property

1 participant