-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Incorrect parameter rewriting for string StartsWith/EndsWith/Contains #32432
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
Comments
Reopening to consider patching. |
…Contains (dotnet#32433) Fixes dotnet#32432 (cherry picked from commit 74cc719)
…Contains Fixes dotnet#32432 (cherry picked from commit 74cc719)
I have this problem. look my c# Look the SQL, Has created 2 parameters, but with the same value. it's wrong look the where clause was expected the parameters values like this
in another words. The value of @__Term_0_rewritten shold be "LIKE" with N'%D%';` |
i think its ok , but when 8.0.2 will be released? |
When a parameter is used as the pattern for StartsWith/EndsWith/Contains, in 8.0.0 we rewrite that parameter to escape any wildchars. However, when the same parameter is reused in two different such methods (e.g. StartsWith and Contains), the same parameter name is used, with the second overwriting the first.
Repro:
This produces the following query:
The StartsWith here is translated to the first LIKE, which incorrectly uses the same parameter as the Contains, with
%foo%
instead offoo%
.The workaround is to use two separate variables.
Introduced in #31482. Originally flagged by @stevenpua for PostgreSQL in npgsql/efcore.pg#2994.
The text was updated successfully, but these errors were encountered: