Skip to content

Stop moving pending selector after DefaultIfEmpty in nav expansion #36241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

roji
Copy link
Member

@roji roji commented Jun 12, 2025

This changes the NavigationExpandingExpressionVisitor around DefaultIfEmpty, applying any pending selector; this prevents any Select prior to the DIE from being moved after it.

This unfortunately caused some complications... Nav expansion was also previously responsible for adding a coalesce for value types, and relied on the fact that the Select gets moved after the DIE. Now that the Select stays before the DIE, the coalesce gets optimized away as it's not yet needed (the column hasn't yet been made nullable by DIE).

This logic doesn't strictly-speaking belong in nav expansion (or anywhere in preprocessing), and this PR moves it to the translation phase of DIE instead (translation was already handling making projected columns nullable, and is the right place for also applying a COALESCE when necessary).

Fixes #36208

@roji roji force-pushed the DefaultIfEmptySelect branch 3 times, most recently from 67e5859 to bb3024a Compare June 13, 2025 14:21
@roji roji marked this pull request as ready for review June 13, 2025 14:50
@roji roji requested review from a team, AndriySvyryd and cincuranet as code owners June 13, 2025 14:50
@roji roji force-pushed the DefaultIfEmptySelect branch from bb3024a to c44c567 Compare June 13, 2025 14:51
_entityReferenceOptionalMarkingExpressionVisitor.Visit(pendingSelector);
if (!pendingSelector.Type.IsNullableType())
{
pendingSelector = Expression.Coalesce(
Copy link
Member Author

Choose a reason for hiding this comment

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

Note the removal of Coalesce which was added (see main PR notes for context).

@roji roji merged commit 35cd115 into dotnet:main Jun 23, 2025
7 checks passed
@roji roji deleted the DefaultIfEmptySelect branch June 23, 2025 12:31
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.

NavigationExpandingExpressionVisitor moves Select() behind DefaultIfEmpty()
2 participants