Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

roji
Copy link
Member

@roji roji commented Sep 12, 2024

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 enabled auto-merge (squash) September 12, 2024 19:54
@roji roji merged commit 3df883b into dotnet:release/9.0 Sep 12, 2024
7 checks passed
@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