Skip to content

Fix collection conversion with nullable element converters - #3965

Merged
roji merged 1 commit into
mainfrom
roji-contains-conversion-triage
Oct 15, 2026
Merged

roji merged 1 commit into
mainfrom
roji-contains-conversion-triage

Conversation

@roji

@roji roji commented Oct 15, 2026

Copy link
Copy Markdown
Member

Contains over a non-nullable collection can throw when the compared property has a nullable value converter, such as an int[] parameter against an int? property converted to string.

Adapt the element conversion lambda's input and output to the collection element types while preserving existing null handling. Add round-trip coverage for arrays and lists, and enable the existing inherited nullable-converter query test with SQL assertions instead of expecting an exception.

Fixes #3919

Adapt converter input and output nullability to collection element types, preserving null handling.

Fixes #3919

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: dcbb7a7a-9347-4d30-8206-8351ec6ef978
Copilot AI balanced review requested due to automatic review settings October 15, 2026 11:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused conversion fix preserves null handling and includes regression coverage, with no blocking issues identified.

0 open findings

What changed in this PR

Fixes #3919 by allowing collection conversions to use nullable element converters in the PostgreSQL provider.

Changes:

  • Adapts converter inputs and outputs to collection element types while preserving null handling.
  • Adds array and list round-trip regression tests.
  • Enables the inherited nullable-converter query test with SQL assertions.
File Description
test/​EFCore.PG.Tests/​Storage/​NpgsqlArrayValueConverterTest.cs Adds array and list regression coverage.
test/​EFCore.PG.FunctionalTests/​Query/​PrimitiveCollectionsQueryNpgsqlTest.cs Replaces the expected exception with SQL assertions.
src/​EFCore.PG/​Storage/​ValueConversion/​NpgsqlArrayConverter.cs Adapts element conversion types.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@roji
roji merged commit d33cdd4 into main Oct 15, 2026
16 checks passed
@roji
roji deleted the roji-contains-conversion-triage branch October 15, 2026 12:08
roji added a commit that referenced this pull request Oct 15, 2026
) (#3967)

Backport d33cdd4 to hotfix/10.0.4 without changes.

Fixes #3919

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: a0c9ca96-101e-4909-bd99-0bc2e723f0d6
roji added a commit that referenced this pull request Oct 15, 2026
…) (#3968)

Backport d33cdd4 to hotfix/9.0.5. Adapt element conversion input and output nullability while preserving existing null guards, with array/list round-trip coverage.

The inherited nullable-comparer functional test from the original change is not available on this release branch.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: b08c8c16-d069-4af1-a1b5-735487e9680b
roji added a commit that referenced this pull request Oct 15, 2026
…) (#3969)

Adapt element conversion input and output nullability while preserving null guards. Backport the array and list regression tests; the inherited nullable-comparer query test is unavailable in EF8.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cdf2d065-d9c8-4f52-85ea-379a40d76928
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.

TargetInvocationException when using Contains with non nullable value types with HasConversion

2 participants