Skip to content

[8.0] Fix byte-array projections from JSON collections - #4075

Merged
roji merged 1 commit into
hotfix/8.0.12from
roji-json-binary-backport-8-0
Oct 22, 2026
Merged

roji merged 1 commit into
hotfix/8.0.12from
roji-json-binary-backport-8-0

Conversation

@roji

@roji roji commented Oct 22, 2026

Copy link
Copy Markdown
Member

Backport of #4067 (merged commit c1ac3e1).

Fixes #3566.

Extract binary fields from json_to_recordset/jsonb_to_recordset as text and decode their base64 representation after relational projection application. Rewrite projections, predicates, and correlated references while retaining the original binary mapping and flat SQL; scalar JSON decoding is unchanged.

EF8 adaptations:

  • Use table identity and owning SelectExpressions to create EF8 column expressions, rather than relying on newer alias/column APIs.
  • Use owned ToJson collection mapping in the existing shared JSON fixture. EF8 hardcodes owned JSON containers to the default jsonb mapping and has no supported json column-type configuration API, so functional coverage is intentionally limited to jsonb.
  • Preserve the visitor summary and explanatory comments; no dependency upgrades or newer warning suppressions.

Regression coverage checks sync/async full-document materialization against collection projections for [0, 1, 127, 128, 255], empty arrays, and null, plus server-side binary equality and correlated references. SQL baselines confirm text extraction and decode without wrapper subqueries.

Validation on pinned EF Core 8.0.32 and an isolated PostgreSQL 18.4 instance: both new cases reproduced the incorrect base64-text bytes before the fix; the shared JSON query and ad-hoc JSON suites pass afterward (441 passed, 11 existing skips).

dotnet test test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj --no-restore --filter 'FullyQualifiedName~JsonQueryNpgsqlTest|FullyQualifiedName~JsonQueryAdHocNpgsqlTest' --verbosity minimal

Targets hotfix/8.0.12.

Backport #4067 using EF8 table identities and owning selects to decode base64 recordset fields without wrapper subqueries. Add owned-JSON regression coverage, including correlated references.

Fixes #3566

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c8a1b67d-06d1-4128-b3e6-3679f8634267
@roji
roji merged commit 34aef6e into hotfix/8.0.12 Oct 22, 2026
6 of 7 checks passed
@roji
roji deleted the roji-json-binary-backport-8-0 branch October 22, 2026 12:55
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.

Byte array in owned entity mapped to JSON returns different value when using projection

1 participant