[release/10.0] Correct COALESCE logic for DefaultIfEmpty (#37233)#37237
Merged
roji merged 1 commit intodotnet:release/10.0from Nov 25, 2025
Merged
[release/10.0] Correct COALESCE logic for DefaultIfEmpty (#37233)#37237roji merged 1 commit intodotnet:release/10.0from
roji merged 1 commit intodotnet:release/10.0from
Conversation
Closes dotnet#37178 (cherry picked from commit 48b0897)
artl93
approved these changes
Nov 25, 2025
Member
artl93
left a comment
There was a problem hiding this comment.
Customer reported, regression, data corruption.
cincuranet
approved these changes
Nov 25, 2025
This was referenced Nov 25, 2025
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.
Backports #37233
Closes #37178
Description
10.0 contained various bug fixes to EF's DefaultIfEmpty() LINQ operator translation. One of these bugfixes required making changes to how COALESCE() is added for non-nullable value types, where we need to return the CLR default (e.g. zero for int) rather than NULL. Unfortunately, to determine whether the return value is a non-nullable value type, an incorrect type was consulted in the SQL tree, which indicates a non-nullable value type even when the returned value is in fact a nullable value type.
Customer impact
In cases where DefaultIfEmpty() is used over a nullable value type, NULL is not returned as expected, but rather than CLR default.
This is a data corruption bug, indicating that there's data in the database (zero), where in fact there's no data (and NULL should be returned).
How found
Customer reported on 10.0.0
Regression
Yes, from 9.0.
Testing
Added.
Risk
Low, very targeted fix (most code in this PR only flows information in, actual behavioral change is a one-liner). Quirk added.