Skip to content

Conversation

@ChrisJollyAU
Copy link
Member

As part of updating to .Net 10, found a bug with the Math.Truncate translation.

Math.Truncate rounds towards 0.
We were originally using the function INT however that always rounds down. So negative values were rounded away from 0.
The other function FIX has the correct behaviour

@ChrisJollyAU ChrisJollyAU requested a review from Copilot July 22, 2025 15:49
@ChrisJollyAU ChrisJollyAU self-assigned this Jul 22, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the Math.Truncate translation for the EF Core Jet provider by changing the SQL function from INT to FIX. The issue was that INT always rounds down (floor behavior), while Math.Truncate should round towards zero, which FIX correctly implements for both positive and negative numbers.

  • Changed SQL function translation from INT to FIX in JetMathTranslator
  • Updated all test assertions to reflect the corrected SQL generation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs Updated the Math.Truncate translation to use FIX instead of INT function
test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs Updated test assertions to expect FIX function calls in generated SQL queries

@ChrisJollyAU ChrisJollyAU added this to the 9.0.0 milestone Jul 22, 2025
@ChrisJollyAU ChrisJollyAU merged commit 325ea97 into CirrusRedOrg:master Jul 23, 2025
24 of 25 checks passed
@ChrisJollyAU ChrisJollyAU deleted the mathtruncate branch July 23, 2025 14:27
ChrisJollyAU added a commit to ChrisJollyAU/EntityFrameworkCore.Jet that referenced this pull request Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant