-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix SQLite decimal comparison with turkish culture #37429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
[release/10.0] Source code updates from dotnet/dotnet
[release/10.0] Source code updates from dotnet/dotnet
Updated decimal parsing in EF_DECIMAL collation to use CultureInfo.InvariantCulture for consistent ordering across cultures. Added a test to verify correct ordering of decimal values under Turkish culture.
Eliminated the unnecessary 'using System.Globalization;' directive from BuiltInDataTypesSqliteTest.cs to clean up the code.
There was a problem hiding this 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 culture-specific bug in SQLite decimal comparison where using Turkish culture (or any culture with a different decimal separator) would cause incorrect sorting of decimal values.
- Updated the
EF_DECIMALcollation to parse decimal strings usingCultureInfo.InvariantCulture - Added comprehensive test coverage for decimal ordering under Turkish culture (tr-TR)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/EFCore.Sqlite.Core/Storage/Internal/SqliteRelationalConnection.cs |
Updated the EF_DECIMAL collation to use InvariantCulture when parsing decimal strings, fixing culture-sensitive comparison issues |
test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs |
Added test with Turkish culture to verify decimal ordering works correctly regardless of application culture |
| decimal.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture), | ||
| decimal.Parse(y, NumberStyles.Any, CultureInfo.InvariantCulture))); |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using NumberStyles.Any for parsing decimal values from the database might be too permissive. NumberStyles.Any includes support for currency symbols, thousands separators, parentheses for negatives, and other formatting that shouldn't appear in SQLite's decimal storage format. Consider using a more restrictive NumberStyles value like NumberStyles.Number or NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign to more accurately match the expected format of decimal values stored in SQLite.
| decimal.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture), | |
| decimal.Parse(y, NumberStyles.Any, CultureInfo.InvariantCulture))); | |
| decimal.Parse(x, NumberStyles.Number, CultureInfo.InvariantCulture), | |
| decimal.Parse(y, NumberStyles.Number, CultureInfo.InvariantCulture))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@salihozkara this comment seems to make sense?
Adjusted the TestDecimal values for test entities in Can_query_OrderBy_decimal_with_Turkish_culture to ensure correct ordering and test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Can you please open an issue? We try to always have an issue - especially when there's a bug - so that it's clear which release contains what, and when a bug was fixed, etc. |
|
roji
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting a fix! See below for some comments.
|
|
||
| <PropertyGroup Label="Version settings"> | ||
| <VersionPrefix>10.0.2</VersionPrefix> | ||
| <VersionPrefix>10.0.3</VersionPrefix> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert, we handle version bumps separately.
| decimal.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture), | ||
| decimal.Parse(y, NumberStyles.Any, CultureInfo.InvariantCulture))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@salihozkara this comment seems to make sense?
| } | ||
|
|
||
| [ConditionalFact, UseCulture("tr-TR")] | ||
| public virtual void Can_query_OrderBy_decimal_with_Turkish_culture() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please reduce this test to the bare minimum, removing all the unneeded stuff? Check out the minimal repro posted here.
Fixes #37432
Summary of the changes
Details
SqliteConnection.CreateCollationto useCultureInfo.InvariantCulturewhen parsing decimal stringsFixes
This addresses the issue where SQLite decimal comparison would fail when the application was running under a culture that uses a different decimal separator (e.g., Turkish using comma instead of period).