Skip to content

Commit e7bdd1d

Browse files
committed
Math.Truncate rounds towards 0. Use FIX instead of INT to match that behaviour (CirrusRedOrg#282)
1 parent 7063662 commit e7bdd1d

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public class JetMathTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMe
226226
resultType = typeof(double);
227227
}
228228
var result = (SqlExpression)_sqlExpressionFactory.Function(
229-
"INT",
229+
"FIX",
230230
[argument],
231231
nullable: true,
232232
argumentsPropagateNullability: [true],

test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public override async Task Sum_over_truncate_works_correctly_in_projection(bool
8181
AssertSql(
8282
"""
8383
SELECT `o`.`OrderID`, (
84-
SELECT IIF(SUM(INT(`o0`.`UnitPrice`)) IS NULL, 0.0, SUM(INT(`o0`.`UnitPrice`)))
84+
SELECT IIF(SUM(FIX(`o0`.`UnitPrice`)) IS NULL, 0.0, SUM(FIX(`o0`.`UnitPrice`)))
8585
FROM `Order Details` AS `o0`
8686
WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum`
8787
FROM `Orders` AS `o`
@@ -96,7 +96,7 @@ public override async Task Sum_over_truncate_works_correctly_in_projection_2(boo
9696
AssertSql(
9797
"""
9898
SELECT `o`.`OrderID`, (
99-
SELECT IIF(SUM(INT(`o0`.`UnitPrice` * `o0`.`UnitPrice`)) IS NULL, 0.0, SUM(INT(`o0`.`UnitPrice` * `o0`.`UnitPrice`)))
99+
SELECT IIF(SUM(FIX(`o0`.`UnitPrice` * `o0`.`UnitPrice`)) IS NULL, 0.0, SUM(FIX(`o0`.`UnitPrice` * `o0`.`UnitPrice`)))
100100
FROM `Order Details` AS `o0`
101101
WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum`
102102
FROM `Orders` AS `o`

0 commit comments

Comments
 (0)