Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Jun 11, 2025

Fixes #35950

Description
See #35950 (comment) for a detailed explanation of what's going on. tl;dr a COALESCE optimization done in 9.0 exposed a previously-existing, latent bug with columns not being considered nullable though they're after DefaultIfEmpty.

Customer impact
Some queries involving the DefaultIfEmpty() operator which worked in EF 8.0 started failing in EF 9.0.

Note that various other bugfixes to DefaultIfEmpty have been done in 10.0 (#36208, #33343, #19095) - this continues those fixes to substantially improve DefaultIfEmpty support in general.

How found
User-reported

Regression
Yes, from 8.0 to 9.0.

Testing
Added

Risk
Low, targeted fix for the specific scenario.

@roji roji requested a review from a team as a code owner June 11, 2025 21:00
@roji roji marked this pull request as draft June 15, 2025 19:49
@roji roji force-pushed the SelectManyNullability branch 2 times, most recently from 419975b to 54a1bc9 Compare June 23, 2025 20:19
@roji roji marked this pull request as ready for review June 23, 2025 20:59
@roji roji requested a review from cincuranet June 23, 2025 20:59
@roji roji enabled auto-merge (squash) June 23, 2025 20:59
@roji roji marked this pull request as draft June 23, 2025 21:09
auto-merge was automatically disabled June 23, 2025 21:09

Pull request was converted to draft

@roji roji force-pushed the SelectManyNullability branch from 54a1bc9 to a749bf5 Compare September 10, 2025 13:45
@roji roji changed the base branch from main to release/10.0 September 10, 2025 13:46
@roji roji requested a review from artl93 September 10, 2025 14:47
@roji roji marked this pull request as ready for review September 10, 2025 14:47
@roji roji changed the title Fix DefaultIfEmpty and nullability within SelectMany selector [rc2] Fix DefaultIfEmpty and nullability within SelectMany selector Sep 10, 2025
@roji roji added the ask-mode label Sep 10, 2025
Copy link
Member

@artl93 artl93 left a comment

Choose a reason for hiding this comment

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

RC2

Assert.Equal(
CoreStrings.ExpressionParameterizationExceptionSensitive(
"value(Microsoft.EntityFrameworkCore.Query.NorthwindMiscellaneousQueryTestBase`1+<>c__DisplayClass175_0[Microsoft.EntityFrameworkCore.Query.NorthwindQueryCosmosFixture`1[Microsoft.EntityFrameworkCore.TestUtilities.NoopModelCustomizer]]).ss.Set().Any()"),
"value(Microsoft.EntityFrameworkCore.Query.NorthwindMiscellaneousQueryTestBase`1+<>c__DisplayClass177_0[Microsoft.EntityFrameworkCore.Query.NorthwindQueryCosmosFixture`1[Microsoft.EntityFrameworkCore.TestUtilities.NoopModelCustomizer]]).ss.Set().Any()"),
Copy link
Member

Choose a reason for hiding this comment

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

Consider using Contains to avoid having a compiler-generated string in the assert

Copy link
Member Author

Choose a reason for hiding this comment

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

What makes this slightly tricky is that the compiler-generated component is integrated inside the CoreStrings template etc... If it starts happening frequently we can think about a better way...

@roji roji merged commit 1d1b41f into dotnet:release/10.0 Sep 10, 2025
6 checks passed
@roji roji deleted the SelectManyNullability branch September 10, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EF Core 9 no longer applies COALESCE in SQL translation for DefaultIfEmpty() which causing an InvalidOperationException

4 participants