Fix compiled queries with IsOneOf and array parameters#4217
Merged
jeremydmiller merged 1 commit intomasterfrom Mar 29, 2026
Merged
Fix compiled queries with IsOneOf and array parameters#4217jeremydmiller merged 1 commit intomasterfrom
jeremydmiller merged 1 commit intomasterfrom
Conversation
…anning Array-typed properties (string[], Guid[], int[], etc.) on compiled query classes were incorrectly classified as Include members because string[] implements IList<string>. This caused IsOneOf() parameters to be hardcoded with template values instead of reading from the query instance. The fix has four parts: 1. CompiledQueryPlan.sortMembers: check for array types with known element-type finders BEFORE the IList<> check 2. ArrayParameterFinder<T>: new finder that matches T[] types and provides unique array values for query planning 3. QueryMember.tryToFind: use structural array comparison instead of reference equality when matching parameter values 4. ParameterUsage.generateSimpleCode: emit correct composite NpgsqlDbType (Array | ElementType) for array parameters Closes #4202 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 30, 2026
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.
Summary
Fixes compiled queries that use
IsOneOf()with array-typed parameters (e.g.,string[]) andIQueryPlanning. Previously,string[]properties on compiled query classes were incorrectly classified as Include members (becausestring[]implementsIList<string>), causing the parameter to be hardcoded with the template value instead of reading from the query instance at runtime.Root cause:
CompiledQueryPlan.sortMembers()checkedIList<>before checking if the type was an array with a known parameter finder. Sincestring[]implementsIList<string>, it was added toIncludeMembersinstead ofQueryMembers.The fix has four parts:
IList<>checkT[]types and provides unique array values for query planningNpgsqlDbType(Array | ElementType) for array parametersSupersedes #4202 (includes the test from that PR plus the fix)
Test plan
can_search_isOneOf_strings_with_compiled_queries_and_query_planningpassesnuke compile🤖 Generated with Claude Code