SmartGWT LGPL 6.0p, nightly build 2018-01-03, SmartClient Version: v11.0p_2018-01-03/LGPL Development Only (built 2018-01-03)
We have a server backend that returns double precision floats from the database. We use these floats to order a list of items in a predicted order. We have been debugging an intermittent problem with IE family of browsers (tested with IE 10, 11 and Edge) where our whole component breaks down. By debugging, we noticed that the float values in records were for some reason Strings instead of numbers. The problem does not occur with Chrome or Firefox.
For example, If we have a DataSourceFloatField in our data source and the server returns "325.71428571428584" for this field, with IE, the record ends up having an incorrect data type in the attribute (string instead of a number).
We ran a debugger through this and noticed that DataSource.recordsFromXML call goes through Validators.js code which has this function in it we trip into:
It seems that IE loses some precision on the float when there are so many digits returned from the database. Then the code leaves the value as a String which breaks down our app completely. Why is this? Is there a workaround that we could use to allow the loss of precision and return correctly typed Records instead of invalid records from the data source (in our case it would be preferred).
By the way, wouldn't it be a more sensible runtime behavior to throw an Exception when a loss of precision is detected or at least log an error/warning we could trace the problem in to? Tracking this down from an obfuscated production code was a bit of a pain.
We have a server backend that returns double precision floats from the database. We use these floats to order a list of items in a predicted order. We have been debugging an intermittent problem with IE family of browsers (tested with IE 10, 11 and Edge) where our whole component breaks down. By debugging, we noticed that the float values in records were for some reason Strings instead of numbers. The problem does not occur with Chrome or Firefox.
For example, If we have a DataSourceFloatField in our data source and the server returns "325.71428571428584" for this field, with IE, the record ends up having an incorrect data type in the attribute (string instead of a number).
We ran a debugger through this and noticed that DataSource.recordsFromXML call goes through Validators.js code which has this function in it we trip into:
Code:
... isFloat: { type:"isFloat", description:"Value is a floating point number", valueType:"none", dataType:"none", condition : function (item, validator, value) { ... // If stringInBrowser is not defined and loosing precision - leave string value. if (isc.booleanValue(item.stringInBrowser, true) !== false && isc.isA.String(value) && lostPrecision) { validator.resultingValue = value; return true; } ...
By the way, wouldn't it be a more sensible runtime behavior to throw an Exception when a loss of precision is detected or at least log an error/warning we could trace the problem in to? Tracking this down from an obfuscated production code was a bit of a pain.
Comment