-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[release/9.0] Avoid using ^
and ~
when invalid because of value converters
#35241
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
Conversation
…net#35124) The transformation of equality/in-equality in a (negated) XOR is only possible when the expressions are BIT or integer types on the SQL side (i.e. taking value conversion into account). Similarly, the Boolean negation `NOT` can be implemented as `~` only if the underlying expression is a BIT. Fixes dotnet#35093. (cherry picked from commit e6abfdd)
Servicing approved via email. |
Sorry, team: is this fix already released to general audience? I upgraded my .NET 8 API project to .NET 9 today and immediately started getting loads of errors on SQL server side with this very issue in the scope. Since all of my EF statements are auto-generated with Hot Chocolate 14 instead of manually constructed, I have no control over it and rely on your fix in the EF Core that you were discussing. Is this already released and can be pulled via Nuget package update yet? |
@SurgeOccm It will be released this month in 9.0.1 |
Thank you Andriy, very much appreciated! |
Fixes #35093
Backports #35124
Description
EF 9 brings many improvements to SQL generation (list). One of these, which also improves query performance, applies bit arithmetic (XOR) to implement equality in contexts where SQL Server requires a BIT value (as opposed to a search condition, so projected SELECT values rather than WHERE predicates).
Unfortunately, the SQL optimization was implemented too widely, applying also on value-converted values, which is incorrect.
Customer impact
Queries on SQL Server which involve equality with a value-converted value sometimes generate invalid SQL and fail. For example:
This scenario is particularly common with value-converted enums, and so has the potential to affect many users. The fix is trivial and low-risk.
How found
Customer reported on 9.
Regression
Yes, from 8.
Testing
Tests added.
Risk
Low and quirked.
/cc @ranma42