[release/9.0] Avoid using ^
and ~
when invalid because of value converters
#35241
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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