diff --git a/src/EFCore.Jet/Storage/Internal/JetDoubleTypeMapping.cs b/src/EFCore.Jet/Storage/Internal/JetDoubleTypeMapping.cs index bca364c..505de44 100644 --- a/src/EFCore.Jet/Storage/Internal/JetDoubleTypeMapping.cs +++ b/src/EFCore.Jet/Storage/Internal/JetDoubleTypeMapping.cs @@ -34,7 +34,7 @@ namespace EntityFrameworkCore.Jet.Storage.Internal //-1.23456789 can have multiple 9s at the end //Base uses format of G17 var doubleValue = Convert.ToDouble(value); - var literal = doubleValue.ToString("G", CultureInfo.InvariantCulture); + var literal = doubleValue.ToString("G15", CultureInfo.InvariantCulture); return !literal.Contains('E') && !literal.Contains('e') diff --git a/src/EFCore.Jet/Storage/Internal/JetFloatTypeMapping.cs b/src/EFCore.Jet/Storage/Internal/JetFloatTypeMapping.cs index 5122d2a..0a5e0d6 100644 --- a/src/EFCore.Jet/Storage/Internal/JetFloatTypeMapping.cs +++ b/src/EFCore.Jet/Storage/Internal/JetFloatTypeMapping.cs @@ -2,6 +2,8 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Storage; +using System.Globalization; +using System; namespace EntityFrameworkCore.Jet.Storage.Internal { @@ -25,5 +27,15 @@ namespace EntityFrameworkCore.Jet.Storage.Internal { return base.ProcessStoreType(parameters, storeTypeNameBase, storeTypeNameBase); } + + /// + /// Generates the SQL representation of a literal value. + /// + /// The literal value. + /// + /// The generated string. + /// + protected override string GenerateNonNullSqlLiteral(object value) + => Convert.ToSingle(value).ToString("G7", CultureInfo.InvariantCulture); } } diff --git a/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs b/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs index 26f9a55..60d5711 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs @@ -902,7 +902,7 @@ WHERE `o`.`Quantity` < 5 AND FIX(`o`.`UnitPrice`) > 10.0"); AssertSql( $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE CDBL(`o`.`Discount`)^3.0 > 0.004999999888241291"); +WHERE CDBL(`o`.`Discount`)^3.0 > 0.00499999988824129"); } public override async Task Where_math_square(bool async) @@ -913,7 +913,7 @@ WHERE CDBL(`o`.`Discount`)^3.0 > 0.004999999888241291"); """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE CDBL(`o`.`Discount`)^2.0 > 0.05000000074505806 +WHERE CDBL(`o`.`Discount`)^2.0 > 0.0500000007450581 """); } @@ -1044,7 +1044,7 @@ WHERE `o`.`OrderID` = 11077 AND EXP(CDBL(`o`.`Discount`)) > 1.0"); AssertSql( $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND `o`.`Discount` > 0 AND (LOG(CDBL(`o`.`Discount`)) / 2.302585092994046) < 0.0"); +WHERE `o`.`OrderID` = 11077 AND `o`.`Discount` > 0 AND (LOG(CDBL(`o`.`Discount`)) / 2.30258509299405) < 0.0"); } public override async Task Where_math_log(bool isAsync) @@ -1084,7 +1084,7 @@ WHERE `o`.`OrderID` = 11077 AND SQR(CDBL(`o`.`Discount`)) > 0.0"); AssertSql( $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND (1.5707963267948966 + ATN(-CDBL(`o`.`Discount`) / SQR(-(CDBL(`o`.`Discount`) * CDBL(`o`.`Discount`)) + 1.0))) > 1.0"); +WHERE `o`.`OrderID` = 11077 AND (1.5707963267949 + ATN(-CDBL(`o`.`Discount`) / SQR(-(CDBL(`o`.`Discount`) * CDBL(`o`.`Discount`)) + 1.0))) > 1.0"); } public override async Task Where_math_asin(bool isAsync) @@ -1183,7 +1183,7 @@ WHERE `o`.`OrderID` = 11077 AND SGN(`o`.`Discount`) > 0"); """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND (CDBL(`o`.`Discount`) * (180.0 / 3.141592653589793)) > 0.0 +WHERE `o`.`OrderID` = 11077 AND (CDBL(`o`.`Discount`) * (180.0 / 3.14159265358979)) > 0.0 """); } @@ -1195,7 +1195,7 @@ WHERE `o`.`OrderID` = 11077 AND (CDBL(`o`.`Discount`) * (180.0 / 3.1415926535897 """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND (CDBL(`o`.`Discount`) * (3.141592653589793 / 180.0)) > 0.0 +WHERE `o`.`OrderID` = 11077 AND (CDBL(`o`.`Discount`) * (3.14159265358979 / 180.0)) > 0.0 """); } @@ -1339,7 +1339,7 @@ WHERE `o`.`OrderID` = 11077 AND EXP(`o`.`Discount`) > 1 """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND `o`.`Discount` > 0 AND (LOG(`o`.`Discount`) / 2.3025851) < 0 +WHERE `o`.`OrderID` = 11077 AND `o`.`Discount` > 0 AND (LOG(`o`.`Discount`) / 2.302585) < 0 """); } @@ -1387,7 +1387,7 @@ WHERE `o`.`OrderID` = 11077 AND SQR(`o`.`Discount`) > 0 """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND (1.5707963267948966 + ATN(-`o`.`Discount` / SQR(-(`o`.`Discount` * `o`.`Discount`) + 1))) > 1.0 +WHERE `o`.`OrderID` = 11077 AND (1.5707963267949 + ATN(-`o`.`Discount` / SQR(-(`o`.`Discount` * `o`.`Discount`) + 1))) > 1.0 """); } @@ -1483,7 +1483,7 @@ WHERE `o`.`OrderID` = 11077 AND SGN(`o`.`Discount`) > 0 """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND (`o`.`Discount` * (180 / 3.1415927)) > 0 +WHERE `o`.`OrderID` = 11077 AND (`o`.`Discount` * (180 / 3.141593)) > 0 """); } @@ -1495,7 +1495,7 @@ WHERE `o`.`OrderID` = 11077 AND (`o`.`Discount` * (180 / 3.1415927)) > 0 """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE `o`.`OrderID` = 11077 AND (`o`.`Discount` * (3.1415927 / 180)) > 0 +WHERE `o`.`OrderID` = 11077 AND (`o`.`Discount` * (3.141593 / 180)) > 0 """); }