Skip to content

[release/11.0] Preserve null compensation for JSON complex properties in left joins - #39751

Open
AndriySvyryd wants to merge 2 commits into
release/11.0from
copilot/fix-left-join-null-compensation
Open

AndriySvyryd wants to merge 2 commits into
release/11.0from
copilot/fix-left-join-null-compensation

Conversation

@AndriySvyryd

@AndriySvyryd AndriySvyryd commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Fixes #39523
Ports #39524

Description
Propagate nullability into JSON complex-type query expressions on the optional side of a left join, preserving null compensation in filters.

Customer impact
Affected queries can silently omit unmatched rows on SQL Server and SQLite. No workaround is known.

How found
Customer-reported on 11.0.0-rc.3.

Regression
Yes, from 10.0.*

Testing
Added direct, nested and subquery regression cases.

Risk
Low: the change is limited to propagating nullability for JSON complex-type shapers; provider-specific regression coverage was added.

@AndriySvyryd AndriySvyryd changed the title [WIP] Fix filtering on JSON complex property over left join Preserve null compensation for JSON complex properties in left joins Nov 21, 2026
@AndriySvyryd
AndriySvyryd requested a lite review from Copilot November 21, 2026 01:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported, and the change is supported by targeted regression tests and provider-specific SQL baselines for the affected left-join scenarios.

No open issues 🎉

What changed in this PR

This pull request preserves null compensation when filtering JSON-mapped complex properties on the optional side of relational left joins, ensuring unmatched rows are retained.

Changes:

  • Propagates nullable state into JSON query expressions for nullable complex-type shapers.
  • Adds regression tests for direct, nested, and subquery-based left joins.
  • Adds SQLite and SQL Server SQL baselines for the new scenarios and JSON storage modes.
File Description
test/​EFCore.SqlServer.FunctionalTests/​Query/​Associations/​ComplexJson/​ComplexJsonMiscellaneousSqlServerTest.cs Adds SQL Server baselines covering null compensation for native and legacy JSON mappings.
test/​EFCore.Sqlite.FunctionalTests/​Query/​Associations/​ComplexJson/​ComplexJsonMiscellaneousSqliteTest.cs Adds SQLite SQL baselines for the JSON left-join regression scenarios.
test/​EFCore.Relational.Specification.Tests/​Query/​Associations/​ComplexJson/​ComplexJsonMiscellaneousRelationalTestBase.cs Adds provider-independent regression tests for direct, nested, and subquery-based left joins.
src/​EFCore.Relational/​Query/​RelationalStructuralTypeShaperExpression.cs Propagates shaper nullability into JSON query expressions when making complex-type shapers nullable.

Review effort: Lite

@dotnet dotnet deleted a comment from Copilot AI Nov 24, 2026
@AndriySvyryd AndriySvyryd changed the title Preserve null compensation for JSON complex properties in left joins [release/11.0] Preserve null compensation for JSON complex properties in left joins Nov 24, 2026
@AndriySvyryd
AndriySvyryd marked this pull request as ready for review November 24, 2026 01:31
@AndriySvyryd
AndriySvyryd requested a review from a team as a code owner November 24, 2026 01:31
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage

release/11.0 90fd1a7 copilot/fix-left-joi... ae1657d +/-
76% 67% -9%
View coverage of the 10 most impacted files.
File release/11.0 90fd1a7 copilot/fix-left-joi... ae1657d +/-
/Users/runner/w...nal/Snapshot.cs 0% 60% +60%
D:\a\efcore\efc...nal\Snapshot.cs 0% 64% +64%
/home/runner/wo...nal/Snapshot.cs 0% 66% +66%
/home/runner/wo...yTypeBuilder.cs 0% 88% +88%
D:\a\efcore\efc...yTypeBuilder.cs 0% 88% +88%
/Users/runner/w...ngs.Designer.cs 0% 92% +92%
/home/runner/wo...ctExpression.cs 0% 93% +93%
D:\a\efcore\efc...ctExpression.cs 0% 93% +93%
D:\a\efcore\efc...ngs.Designer.cs 0% 94% +94%
/home/runner/wo...ngs.Designer.cs 0% 95% +95%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

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.

Filter on JSON complex property over a LEFT JOIN drops unmatched rows

4 participants