Skip to content

Fix issues with nulls in primitive collections#37674

Merged
roji merged 1 commit intodotnet:mainfrom
roji:SqlServerNullability
Feb 12, 2026
Merged

Fix issues with nulls in primitive collections#37674
roji merged 1 commit intodotnet:mainfrom
roji:SqlServerNullability

Conversation

@roji
Copy link
Copy Markdown
Member

@roji roji commented Feb 11, 2026

Fixes #37605

Thanks to @BurakBebek1 for flagging this and submitting a fix PR in #37600.

@roji roji marked this pull request as ready for review February 12, 2026 00:01
@roji roji requested a review from a team as a code owner February 12, 2026 00:01
Copilot AI review requested due to automatic review settings February 12, 2026 00:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect/null-unaware translation and execution for Contains over nullable primitive collections (especially when SQL Server switches to OPENJSON), ensuring correct matching of NULL elements and avoiding invalid nullable SqlExpression types.

Changes:

  • Update relational null-stripping logic to preserve the original collection element CLR type when rewriting parameters (to keep value converters working correctly).
  • Fix SQL Server OPENJSON ColumnExpression construction to use a non-nullable CLR type while keeping nullability in the separate nullable flag.
  • Add/adjust provider functional tests (SqlServer/Sqlite/Cosmos) for EF.Parameter(...).Contains(...) and add large-collection regression coverage for #37605.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs Adds SQL assertion for EF.Parameter + nullable ints including null semantics (OR ... IS NULL).
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs Adds SQL assertion for OPENJSON + OR ... IS NULL, plus large collection regression test; file also appears to have gained a BOM.
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerJsonTypeTest.cs Adds SQL assertion for OPENJSON + OR ... IS NULL in JSON-type variant.
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServer160Test.cs Adds SQL assertion for OPENJSON + OR ... IS NULL for SQL Server 2016+ coverage.
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs Adds an override expecting EF.Parameter unsupported and adds a large-collection regression test.
test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs Introduces new base test for EF.Parameter(nullableInts).Contains(...) with a null element.
test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs Adds Cosmos SQL assertion for EF.Parameter over nullable ints including null.
src/EFCore.SqlServer/Query/Internal/SqlServerSqlNullabilityProcessor.cs Ensures ColumnExpression type is non-nullable for OPENJSON projection; file also appears to have gained a BOM.
src/EFCore.Relational/Query/SqlNullabilityProcessor.cs Rewrites null-stripping to pick element type from runtime IEnumerable<T> to preserve converter expectations.

Copilot AI review requested due to automatic review settings February 12, 2026 00:16
@roji roji force-pushed the SqlServerNullability branch from 21e9bcf to 47b9700 Compare February 12, 2026 00:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs:1

  • This file now starts with a UTF-8 BOM (invisible character before the first //). Unless the file contains non-ASCII characters that require it, please revert the BOM/encoding-only change to avoid unnecessary diffs and inconsistent encodings across the repo.
// Licensed to the .NET Foundation under one or more agreements.

src/EFCore.SqlServer/Query/Internal/SqlServerSqlNullabilityProcessor.cs:1

  • This file now starts with a UTF-8 BOM (invisible character before the license header). Unless there are non-ASCII characters in the file, please remove the BOM to avoid encoding-only churn and keep file encodings consistent.
// Licensed to the .NET Foundation under one or more agreements.

@roji roji enabled auto-merge (squash) February 12, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants