Skip to content

Fix SQLite decimal comparison with turkish culture#37443

Merged
roji merged 3 commits intodotnet:mainfrom
salihozkara:issue-37432
Jan 3, 2026
Merged

Fix SQLite decimal comparison with turkish culture#37443
roji merged 3 commits intodotnet:mainfrom
salihozkara:issue-37432

Conversation

@salihozkara
Copy link
Contributor

Fixes #37432

Summary of the changes

  • Fixed SQLite decimal collation to use invariant culture for parsing decimal values
  • Ensured correct decimal comparison in SQLite regardless of the application's current culture

Details

  • Updated SqliteConnection.CreateCollation to use CultureInfo.InvariantCulture when parsing decimal strings
  • Added test coverage for decimal ordering with Turkish culture (tr-TR) to verify the fix
  • The issue occurred when the application culture used a different decimal separator (e.g., comma in Turkish), causing incorrect sorting of decimal values

Fixes

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).

Updated SqliteRelationalConnection to parse decimals using CultureInfo.InvariantCulture for collation, ensuring consistent behavior across cultures. Added a test to verify correct ordering of decimal values under Turkish culture.
Copilot AI review requested due to automatic review settings January 3, 2026 08:15
@salihozkara salihozkara requested a review from a team as a code owner January 3, 2026 08:15
@salihozkara salihozkara changed the title Fix decimal collation to use invariant culture Fix SQLite decimal comparison with turkish culture Jan 3, 2026
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 culture-dependent bug in SQLite decimal collation where decimal comparison would fail when the application runs under a culture that uses a different decimal separator (e.g., Turkish using comma instead of period).

  • Updated SqliteRelationalConnection.CreateCollation to use CultureInfo.InvariantCulture when parsing decimal strings
  • Added test coverage with Turkish culture (tr-TR) to verify decimal ordering works correctly regardless of the application's current culture

Reviewed changes

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

File Description
src/EFCore.Sqlite.Core/Storage/Internal/SqliteRelationalConnection.cs Fixed decimal collation to use InvariantCulture when parsing decimal strings, ensuring correct comparison regardless of current culture
test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs Added test with Turkish culture to verify decimal ordering works correctly with cultures that use different decimal separators

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Copilot AI review requested due to automatic review settings January 3, 2026 08:36
@roji roji enabled auto-merge (squash) January 3, 2026 08:36
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

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

@roji roji disabled auto-merge January 3, 2026 08:48
@roji roji enabled auto-merge (squash) January 3, 2026 08:58
@roji roji merged commit 0792cd5 into dotnet:main Jan 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite decimal collation fails under non-invariant cultures (e.g. tr-TR)

4 participants