U4-10947 - Unable to save Decimal Editor data

Created by Robert Copilau 08 Feb 2018, 11:00:26 Updated by Jacob Midtgaard-Olesen 23 Apr 2018, 13:53:59

Relates to: U4-10944

Comments

Robert Copilau 08 Feb 2018, 11:12:55

PR: https://github.com/umbraco/Umbraco-CMS/pull/2433


Stephan 08 Feb 2018, 12:08:28

Have added a comment on the PR, can you have a look?

Also... why was the Nullable thing preventing decimal editor from saving? What I'm not sure of is, we want to convert to ''target'' which is, say, int? aka Nullable - but with your code what we'll return now is not an instance of ''target''?


Robert Copilau 08 Feb 2018, 12:26:55

The problem I encountered was that Convert.ChangeTyper will fail if the target was a nullable type, decimal in our case. I followed this StackOverflow [answer |https://stackoverflow.com/questions/19811583/invalid-cast-from-system-double-to-system-nullable]. "Not a supported usage of Convert.ChangeType. You need to give it the non-nullable form, i.e. double."

"but with your code what we'll return now is not an instance of target?" It will return a "unnullable" instance of target if it was nullable.


Stephan 08 Feb 2018, 12:33:03

Ah so we wanted to convert to eg decimal? right?


Stephan 08 Feb 2018, 12:35:55

Weird, 'cos a simple test such as "100.001".TryConvertTo<decimal?>(); works out-of-the-box?


Stephan 08 Feb 2018, 12:49:30

details: create a content type with a decimal property and try to save some values: no error, but the value is lost.


Robert Copilau 08 Feb 2018, 15:22:14

Update PR: https://github.com/umbraco/Umbraco-CMS/pull/2433/commits/4423571eaa913bb18626325b9ce760d58e075661


Stephan 08 Feb 2018, 15:35:05

Commented on the PR


Shannon Deminick 08 Feb 2018, 23:31:19

I've pushed updates to the PR and commented on it. The resulting changes are pretty minimal.

I've tested:

  • create a content type with a decimal property and try to save some values - it now works
  • change decimal property to be mandatory - it still validates if empty and saves when a value is entered
  • verified this issue is resolved too: http://issues.umbraco.org/issue/U4-10944 ... now datetimes are saved correctly as well


Stephan 09 Feb 2018, 07:15:03

good now, merged


Priority: Major

Type: Bug

State: Fixed

Assignee:

Difficulty:

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.7.9, 7.7.10

Due in version: 7.7.11, 7.8.1

Sprint:

Story Points: 1

Cycle: 8