Skip to content

Preserve row value type mappings when rewriting expressions - #3953

Merged
roji merged 1 commit into
mainfrom
roji-issue-3933-triage
Oct 14, 2026
Merged

roji merged 1 commit into
mainfrom
roji-issue-3933-triage

Conversation

@roji

@roji roji commented Oct 14, 2026

Copy link
Copy Markdown
Member

Tuple projections over query-filtered navigations can lose their type mapping during query rewriting, causing a NullReferenceException when the shaper is compiled.

Preserve TypeMapping in PgRowValueExpression.VisitChildren() and Update(). Adds synchronous/asynchronous regression coverage for the reported query, plus unit coverage for both rewrite paths and unchanged-expression identity.

Fixes #3933

Fix tuple projections over query-filtered navigations losing their type mapping and failing during shaper compilation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4d1edc28-2b78-4a4a-8530-95424e486cad
Copilot AI balanced review requested due to automatic review settings October 14, 2026 19:08
@roji
roji enabled auto-merge (squash) October 14, 2026 19:09

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

The focused fix has appropriate regression coverage and no identified blocking issues; tests were not executed.

0 open findings

What changed in this PR

Fixes #3933 by preserving PostgreSQL row-value type mappings during expression rewriting, preventing tuple-projection failures over query-filtered navigations.

Changes:

  • Retains TypeMapping in VisitChildren() and Update().
  • Adds unit coverage for both rewrite paths and unchanged-expression identity.
  • Adds synchronous and asynchronous regression coverage.
File Description
test/​EFCore.PG.Tests/​Query/​PgRowValueExpressionTest.cs Tests mapping preservation and expression identity.
test/​EFCore.PG.FunctionalTests/​Query/​AdHocQueryFiltersQueryNpgsqlTest.cs Tests tuple projections over filtered navigations.
src/​EFCore.PG/​Query/​Expressions/​Internal/​PgRowValueExpression.cs Preserves mappings when rebuilding row expressions.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@roji
roji merged commit e13f6c8 into main Oct 14, 2026
16 checks passed
@roji
roji deleted the roji-issue-3933-triage branch October 14, 2026 19:21
roji added a commit that referenced this pull request Oct 14, 2026
…3954)

Backport 8912932 from #3953. Adapt the regression to EF Core 10 test initialization APIs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 66919a84-6f97-4ce7-a011-3fd6398bc412
roji added a commit that referenced this pull request Oct 14, 2026
)

* [9.0] Preserve row value type mappings when rewriting expressions

Backport #3953 to 9.0. Adapt the regression to EF 9 test APIs, nullable conventions, and query-filter parameter naming.

(cherry picked from commit 8912932)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 79a22b3a-d5f9-4921-ac7b-3a1b41a9adc1

* Configure tuple mapping locally for row value regression

The global tuple mapping could be enabled after the query-filter test pool was already created, causing test-order-dependent tuple reads to fail. Configure it on the regression data source instead.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 79a22b3a-d5f9-4921-ac7b-3a1b41a9adc1

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 79a22b3a-d5f9-4921-ac7b-3a1b41a9adc1
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.

NullReferenceException in shaper for tuple query when a query-filtered entity is reached via both a scalar and collection navigation

2 participants