Fix ValuesExpression pruning dropping outer columns referenced from VALUES cells - #38779
AndriySvyryd merged 2 commits into
Conversation
|
@dotnet-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Fixes VALUES pruning so nested outer-column references are retained.
Changes:
- Visits VALUES cells during pruning.
- Corrects pruned column-name backfilling.
- Adds relational regression coverage and a SQL Server baseline.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/EFCore.Relational/Query/SqlTreePruner.cs |
Corrects VALUES traversal and column pruning. |
test/EFCore.Relational.Specification.Tests/Query/AdHocQueryFiltersQueryRelationalTestBase.cs |
Adds the regression scenario. |
test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs |
Verifies the generated SQL projection. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
968c7c8 to
60b1d5b
Compare
…ALUES cells - Visit nested RowValues/ValuesParameter in PruneValues so embedded ColumnExpressions are registered before outer join projections are pruned - Fix column-name backfill to use ColumnNames[j] instead of repeating the first unreferenced column's name Fixes dotnet#38700
…tnet#38700) Cover the jk-aau case (inline-array Max + AsSplitQuery + pagination), forcing VALUES+MAX on SQL Server compat < 160.
60b1d5b to
eeee33b
Compare
AndriySvyryd
left a comment
There was a problem hiding this comment.
Thanks for your contribution!
|
@AndriySvyryd Will this PR be patched into the current version (EF 10) or do we have to wait until EF 12? |
|
@jk-aau Currently the issue doesn't have enough votes (👍 reactions) to be considered for 10 or 11 backport. |
|
@AndriySvyryd Following up on the backport question. You already labeled #38700 as We’re a .NET 10 / EF 10.0.11 production app. The issue repro is our access-control engine ( The fix is already in this PR (small |
Fixes #38700
SqlTreePruner.PruneValues(from #36159) copied VALUES row cells withoutVisit(), soColumnExpressions embedded in inline collections were neverregistered. Outer join projections were then over-pruned (e.g. only
Idprojected while
EXISTSstill referencedServiceId).Fix
Visit()nestedRowValues/ValuesParameterinPruneValues(same pattern as OpenJSON pruning)
ColumnNames[j]instead of repeating thefirst unreferenced column's name
Tests
ServiceIdremains in the join projectionNote: approach described on #38700; no maintainer reply after ~1.5 weeks, opening PR for review.