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/8.0] Add method postfix when rewriting parameters for StartsWith/EndsWith/Contains #32440

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

roji
Copy link
Member

@roji roji commented Nov 28, 2023

Fixes #32432, backports #32433.

Description

EF 8.0 optimizes the translations of string.StartsWith/EndsWith/Contains for when the pattern is a parameter:

var pattern = "foo";
var blogs = context.Blogs.Where(b => b.Name.StartsWith(pattern)...

Unfortunately, if the same pattern parameter is used for two different methods in the same query (i.e. Contains and StartsWith), only one parameter is sent to the database, with whatever pattern comes last (i.e. %foo% for Contains, foo% for StartsWith).

Customer impact

When using the same pattern parameter for two different methods in the same query, the query is translated incorrectly and the user may receive incorrect results (data corruption bug).

How found

Customer reported on 8.0

Regression

Yes

Testing

Added.

Risk

Very low; quirk added.

@AndriySvyryd AndriySvyryd added this to the 8.0.2 milestone Dec 1, 2023
@wtgodbe wtgodbe merged commit 2a92582 into dotnet:release/8.0 Jan 3, 2024
7 checks passed
@roji roji deleted the ParameterRewriting8 branch January 3, 2024 23:00
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.

4 participants