From 592a20decd3d32e97948579dce69d0bded27a553 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Sun, 2 Jun 2024 16:57:13 +0200 Subject: [PATCH] Fix SQL Server operator precedence table 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 #30248. --- .../Query/Internal/SqlServerQuerySqlGenerator.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs index 8f73dcf57bb..82caeed7219 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs @@ -649,16 +649,16 @@ protected override bool TryGetOperatorInfo(SqlExpression expression, out int pre ExpressionType.Multiply => (900, true), ExpressionType.Divide => (900, false), ExpressionType.Modulo => (900, false), - ExpressionType.Add => (800, true), - ExpressionType.Subtract => (800, false), + ExpressionType.Add => (700, true), + ExpressionType.Subtract => (700, false), ExpressionType.And => (700, true), ExpressionType.Or => (700, true), ExpressionType.LeftShift => (700, true), ExpressionType.RightShift => (700, true), - ExpressionType.LessThan => (600, false), - ExpressionType.LessThanOrEqual => (600, false), - ExpressionType.GreaterThan => (600, false), - ExpressionType.GreaterThanOrEqual => (600, false), + ExpressionType.LessThan => (500, false), + ExpressionType.LessThanOrEqual => (500, false), + ExpressionType.GreaterThan => (500, false), + ExpressionType.GreaterThanOrEqual => (500, false), ExpressionType.Equal => (500, false), ExpressionType.NotEqual => (500, false), ExpressionType.AndAlso => (200, true),