Skip to content

fix(filter): support the in operator on a property with HasConversion<string> - #218

Closed
IngbertPalm wants to merge 1 commit into
pdevito3:mainfrom
IngbertPalm:feature/in-operator-converted-properties
Closed

IngbertPalm wants to merge 1 commit into
pdevito3:mainfrom
IngbertPalm:feature/in-operator-converted-properties

Conversation

@IngbertPalm

Copy link
Copy Markdown

Fixes #217

Problem

Filter Property Before
Id ^^ ["2","3"] struct, HasConversion<string>() QueryKitParsingException: the ^^ operator needs a list value
Id !^^ ["2","3"] same same
wrappedid ^^ ["1","2"] same, with HasQueryName("wrappedid") same
Id ^^ ["2","3"] nullable struct same
Email ^^ ["b@x.com","c@x.com"] reference type same

Change

CreateRightExprFromType in FilterParser checks for an array literal on a HasConversion<string>()
property before the single-value path. CreateStringConversionArrayExpr builds an array of constants and
constructs each item with the (string) constructor.

  • Nullable structs are constructed from their underlying type.
  • A null item stays null.
  • An empty list [] gives an empty array.
  • The items are split with the existing SplitListItems, so a comma inside a quoted item stays in the item.

No public API changes. A single value, such as Id == "2", takes the same path as before.

Tests

QueryKit.UnitTests/HasConversionTests.cs, 6 new tests: ^^ and !^^ on a struct, ^^ with a query name,
a nullable struct (with a null row), a reference type, and a comma inside a quoted item.
All 6 fail on main with the QueryKitParsingException above and pass with the fix.

  • QueryKit.UnitTests: 874 of 874 pass.
  • QueryKit.IntegrationTests (HasConversion, Postgres): 15 of 15 pass.
  • The change builds on net6.0, net7.0, net8.0, net9.0 and net10.0 with 0 warnings.

Not covered: a ^^ on a converted property against Postgres. The new tests run in memory.

🤖 Generated with Claude Code

…<string>

An array literal such as `Id ^^ ["2","3"]` on a property configured with
HasConversion<string>() was handed to the single-value string constructor
path, so it could not be used with the in (^^) and not-in (!^^) operators.

Build the right side as an array of constants instead, constructing each
item with the (string) constructor. Nullable structs, null items, empty
lists, and properties with a query name are handled.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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 in operator (^^, !^^) does not work on a property with HasConversion<string>

2 participants