Skip to content

[release/9.0] Fix type mapping management for JsonScalarExpression - #34663

Merged
roji merged 1 commit into
dotnet:release/9.0from
roji:JsonScalarTypeMapping
Sep 12, 2024
Merged

roji merged 1 commit into
dotnet:release/9.0from
roji:JsonScalarTypeMapping

Conversation

@roji

@roji roji commented Sep 12, 2024

Copy link
Copy Markdown
Member

Fixes #33582

Description

In 8.0, EF started translating queries using scalar collections. Unfortunately, the type mapping inference for scalar collections (JsonScalarExpression specifically) was flawed, as various infra was missing at the time, and applied the default type mapping in cases where it shouldn't have. This PR fixes type mapping inference for JsonScalarExpression.

Customer impact

Queries using non-column scalar collections could fail in various scenarios. Example:

string[] values = ["one", "two", "three", "four"];
_ = await context.Entities
    .Select(item => item.Id != 0 ? values[item.Value] : "zero")
    .ToListAsync();

How found

Reported by user.

Regression

Yes - from 7.0 to 8.0.

The case in #33582 was previously being client-evaluated (top-level Select); the scalar collection support in 8.0 allowed this to get this translated, but then the translation got blocked by this bug.

Testing

Added.

Risk

Low.

@roji
roji force-pushed the JsonScalarTypeMapping branch from 2760589 to d79ae8b Compare September 12, 2024 19:54
@roji
roji enabled auto-merge (squash) September 12, 2024 19:54
@roji
roji merged commit 3df883b into dotnet:release/9.0 Sep 12, 2024
@roji
roji deleted the JsonScalarTypeMapping branch September 12, 2024 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants