From 3ef1503bb97ef2957838c93312a9f05014c4de05 Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Sat, 22 Jul 2023 17:36:36 +0800 Subject: [PATCH] Translate the Atan2 function --- .../Internal/JetMathTranslator.cs | 13 ++++++++++++- ...NorthwindFunctionsQueryJetTest.Functions.cs | 18 ++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs b/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs index 0c2e6f8..c0a9c10 100644 --- a/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs +++ b/src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs @@ -203,7 +203,18 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal nameof(Math.Floor) => CreateFix(arguments, method.ReturnType), nameof(Math.Ceiling) => CreateCeiling(arguments, method.ReturnType), - + nameof(Math.Atan2) => _sqlExpressionFactory.Function( + "ATN", + new[] + { + _sqlExpressionFactory.Divide( + arguments[0], + arguments[1] + ) + }, + true, + new[] { true }, + method.ReturnType), _ => null, diff --git a/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs b/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs index baecf8c..1fd192f 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs @@ -1067,9 +1067,11 @@ WHERE `o`.`OrderID` = 11077 AND ATN(CDBL(`o`.`Discount`)) > 0.0"); await base.Where_math_atan2(isAsync); AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ATN2(CDBL(`o`.`Discount`), 1.0E0) > 0.0E0)"); + """ + SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` + FROM `Order Details` AS `o` + WHERE `o`.`OrderID` = 11077 AND ATN(CDBL(`o`.`Discount`) / 1.0) > 0.0 + """); } public override async Task Where_math_cos(bool isAsync) @@ -1349,11 +1351,11 @@ WHERE `o`.`OrderID` = 11077 AND ATN(`o`.`Discount`) > 0 await base.Where_mathf_atan2(async); AssertSql( - """ -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND ATN2(`o`.`Discount`, CAST(1 AS real)) > CAST(0 AS real) -"""); + """ + SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` + FROM `Order Details` AS `o` + WHERE `o`.`OrderID` = 11077 AND ATN(`o`.`Discount` / 1) > 0 + """); } public override async Task Where_mathf_cos(bool async)