Repository navigation
Do not use null when padding parameter collection buckets - #39756
Open
lqkhanh295 wants to merge 4 commits into
Open
lqkhanh295 wants to merge 4 commits into
lqkhanh295 wants to merge 4 commits into
Conversation
cincuranet
reviewed
Nov 25, 2026
cincuranet
left a comment
Contributor
There was a problem hiding this comment.
@lqkhanh295 Also add test where all values are null.
Author
|
@cincuranet Added |
- In SqlNullabilityProcessor.ProcessInExpressionValues, bucket padding was repeating values[^1]. When removeNulls was true and the last element of the collection was null, null parameters were added as padding, turning negated Contains into NOT IN (..., NULL) which matches no rows. - Use the last non-null value from the collection for bucket padding when removeNulls is true, or skip padding if all elements were null so case [] can handle it. - Added regression tests in PrimitiveCollectionsQueryRelationalTestBase and SQLite functional tests. Fixes dotnet#39705
lqkhanh295
force-pushed
the
fix/parameter-collection-padding-null-last
branch
from
November 25, 2026 15:25
51f341e to
06ecb7e
Compare
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.

Fixes #39705
Description
In
SqlNullabilityProcessor.ProcessInExpressionValues, parameterized collections underParameterTranslationMode.MultipleParametersadd padding up to the bucket size by repeatingvalues[^1]. WhenremoveNullsis true and the last element of the input collection isnull,nullwas used as the padding value, addingNULLparameters to theINlist. For a negatedContains(NOT IN), having aNULLparameter in SQL meansx NOT IN (..., NULL)evaluates to unknown/false, so no rows are returned.This change uses the last non-null value from the collection for bucket padding when
removeNullsis true. If all elements in the collection were null, padding is skipped so thatcase []can simplify the expression (item IS NULLorfalse).Added regression tests in
PrimitiveCollectionsQueryRelationalTestBaseandPrimitiveCollectionsQuerySqliteTest.