-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Query: incorrect results for a very complex predicate with bitwise operations #30248
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
community-contribution
customer-reported
type-bug
Milestone
Comments
correct results are returned when we add parens around everything like so: SELECT [o].[Value] AS [Value0], [o0].[Value] AS [Value1], [o1].[Value] AS [Value4], [o2].[Value] AS [Value5]
FROM [OperatorEntityLong] AS [o]
CROSS JOIN [OperatorEntityLong] AS [o0]
CROSS JOIN [OperatorEntityLong] AS [o1]
CROSS JOIN [OperatorEntityLong] AS [o2]
--WHERE ([o0].[Value] % CAST(2 AS bigint)) / [o].[Value] & (([o2].[Value] | [o1].[Value]) - [o].[Value]) - [o1].[Value] * [o1].[Value] >= (([o0].[Value] / ~[o2].[Value]) % CAST(2 AS bigint)) % (~[o].[Value] + CAST(1 AS bigint))
WHERE (((([o0].[Value] % CAST(2 AS bigint)) / [o].[Value]) & ((([o2].[Value] | [o1].[Value]) - [o].[Value]) - ([o1].[Value] * [o1].[Value]))) >= ((([o0].[Value] / ~([o2].[Value])) % ((CAST(2 AS bigint)))) % (~([o].[Value]) + CAST(1 AS bigint)))) |
found simpler predicate: (((((e1.Value & (e0.Value + e0.Value)) & e0.Value) / 1) > (e1.Value & (int)((8 + 2)))) && e2.Value) sql we generate: SELECT [o].[Id], [o].[Value], [o0].[Id], [o0].[Value], [o1].[Id], [o1].[Value]
FROM [OperatorEntityInt] AS [o]
CROSS JOIN [OperatorEntityInt] AS [o0]
CROSS JOIN [OperatorEntityBool] AS [o1]
WHERE ([o0].[Value] & [o].[Value] + [o].[Value] & [o].[Value]) / 1 > [o0].[Value] & 10 AND [o1].[Value] = CAST(1 AS bit)
ORDER BY [o].[Id], [o0].[Id], [o1].[Id] sql that produces correct results: SELECT [o].[Id], [o].[Value], [o0].[Id], [o0].[Value], [o1].[Id], [o1].[Value]
FROM [OperatorEntityInt] AS [o]
CROSS JOIN [OperatorEntityInt] AS [o0]
CROSS JOIN [OperatorEntityBool] AS [o1]
--WHERE ([o0].[Value] & [o].[Value] + [o].[Value] & [o].[Value]) / 1 > [o0].[Value] & 10 AND [o1].[Value] = CAST(1 AS bit)
WHERE ((((([o0].[Value] & ([o].[Value] + [o].[Value])) & [o].[Value]) / 1) > ([o0].[Value] & ((10)))) AND [o1].[Value] = CAST(1 as bit))
ORDER BY [o].[Id], [o0].[Id], [o1].[Id] |
related: #30181 |
ranma42
added a commit
to ranma42/efcore
that referenced
this issue
Jun 2, 2024
Specifically, binary logical operators have the same precedence as `+`/`-`. The table is now aligned with the referenced document, plus shift operators. They seem to have the same precedence as `+`/`-` according to manual tests; no documentation about this is available. Also, warn about inconsistent and misleading documentation, which might be the cause of the mismatch between the previous table and the linked documentation. Fixes dotnet#30248.
ranma42
added a commit
to ranma42/efcore
that referenced
this issue
Jun 2, 2024
Specifically, binary logical operators have the same precedence as `+`/`-`. The table is now aligned with the referenced document, plus shift operators. They seem to have the same precedence as `+`/`-` according to manual tests; no documentation about this is available. Fixes dotnet#30248.
roji
pushed a commit
that referenced
this issue
Jun 2, 2024
Specifically, binary logical operators have the same precedence as `+`/`-`. Fixes #30248
maumar
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Jun 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
community-contribution
customer-reported
type-bug
sql generated:
The text was updated successfully, but these errors were encountered: