Skip to content

Translate logical Boolean operators as conditional Boolean operators#33873

Merged
maumar merged 2 commits intodotnet:mainfrom
ranma42:bool-conditional-op
Jun 3, 2024
Merged

Translate logical Boolean operators as conditional Boolean operators#33873
maumar merged 2 commits intodotnet:mainfrom
ranma42:bool-conditional-op

Conversation

@ranma42
Copy link
Copy Markdown
Contributor

@ranma42 ranma42 commented Jun 2, 2024

In C# the expected results of logical Boolean operators are the same as those of the conditional Boolean operators (they differ in not being short-circuited); see here.

Instead, in SQL logical operators propagate NULLs. It is possible to avoid complex translations by simply mapping the logical operators to the corresponding conditional ones for Boolean expressions.

Fixes #30245.

ranma42 added 2 commits June 2, 2024 15:38
In C# the expected results of logical Boolean operators are the same as those of
the conditional Boolean operators, as per the
[documentation](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/boolean-logical-operators#nullable-boolean-logical-operators).

Instead, in SQL logical operators propagate NULLs. It is possible to avoid
complex translations by simply mapping the logical operators to the
corresponding conditional ones for Boolean expressions.

Fixes dotnet#30245.
@maumar maumar merged commit 2c84a6e into dotnet:main Jun 3, 2024
@maumar
Copy link
Copy Markdown
Contributor

maumar commented Jun 3, 2024

great optimization, loving the new sql, thanks @ranma42 !

@ranma42 ranma42 deleted the bool-conditional-op branch June 3, 2024 05:45
ranma42 added a commit to ranma42/efcore that referenced this pull request Jun 3, 2024
After dotnet#33873 EFCore emits different queries for the test.
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.

Query: incorrect results for complex predicate with bitwise AND operation with bool args

3 participants