Skip to content
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

Values saved as decimals on one culture display differently in another when using SQLite. #12757

Closed
AndyButland opened this issue Aug 1, 2022 · 2 comments

Comments

@AndyButland
Copy link
Contributor

AndyButland commented Aug 1, 2022

Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9

10.1

Bug summary

When creating content with a decimal value using one culture and a Sqlite database, when switching cultures to one with a different decimal separator/group separator, the value displayed is not correct.

This issue was originally reported and is shown in this Umbraco Deploy issue, but likely the fix should be in CMS if it's possible as it can be replicated in other scenarios.

Specifics

I'm pretty sure the issue stems from using a TEXT data type for decimals rather than REAL. This was changed in this PR, seemingly for good reason. But coincidentally I had a database from prior to this change and I didn't see the problem in that.

I can see in SQLite Studio the value is stored as "123.0".

So this makes some sense, in that when loading this value under Danish culture, the "." would be considered as a numeric grouping separator leading to a value of "1230", which is what we see in the back-office when following the steps described below.

There's something confusing though. If I create the content using the Danish culture, it's presented correctly under the Danish culture. BUT if I look in the database, the value stored is still 123.0 (i.e. with a "." as the decimal separator). So I don't understand why that displays OK. Seemingly it's the same value that displays incorrectly if you switch cultures.

Steps to reproduce

  • Start using an en-US locale. This can be done via regional settings or (more easily) by adding the following code to the Startup.Configure() method.
    var cultureInfo = new CultureInfo("en-US");

    CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
    CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
  • Create a document type containing a property based on the decimal data type.
  • Create a content item and enter the value "123".
  • Amend the code above to use the Danish culture "da-DK"
  • Restart the application and note that the value is displayed as "1230"

Expected result / actual result

Should display the same across all cultures.

@nikolajlauridsen
Copy link
Contributor

Hey Andy, just had a look and can indeed reproduce following your steps 👍also sounds like it's related to #13135.

For now, I'll go ahead and leave this up for grabs 😄

@Zeegaan
Copy link
Member

Zeegaan commented Jan 30, 2023

This issue is fixed by: #13741, thanks for reporting @AndyButland 🐛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants