Hi, after 6.5.5 update, my application return mysql query numeric (decimal) values as string number+m
I have the same issue.
What database are you using and what server model? Also what is the exact database field type you are using?
See:
Weren't decimal fields supported before? So is there anything different we need to be doing that we haven't done before? Or something that we were doing that we no longer need to do?
I'm just curious as it seems all of my decimal values are displaying correctly. I also use bigint a lot. Is there anything we should know about that?
Decimals fields were becoming regular numbers in client side JavaScript and calculations with those could result in rounding errors.
Now we support decimals and also the special decimal calculations that gives the right results.
Hmmm, so is this still the recommended approach?
<td dmx-text="cost_amount.toNumber().formatCurrency('$', '.', ',', 2)"></td>
You don’t need to convert decimals to number, just format them directly.
Currency formatter does not work with the the output. Either formatted to number or just plain right decimal. Is there something else I should be doing? Plain number still shows my output with "m" and format currency doesnt do anything. It just display Ïnvalid Number"
DId you find a solution @joancarlesadc
Seems to be working for me with PHP/MySQL. What server model and database are you using?
HI @brad Node.js & MySQL (Decimal)
This is what I get without .formatCurrency. With format currency:
Nothing shows
PS: I did a Force Update all framework files when I updated to wappler 6.5.5.
I found you have to convert to number for it to show. So convert your binding to number then format currency. It works for me 'sometimes'.
Hmmm, I don't get the m on the end with a straight binding either?
This displays properly:
<td dmx-text="decimal_value.toNumber().formatCurrency('$', '.', ',', 2)"></td>
This displays nothing:
<td dmx-text="decimal_value.formatCurrency('$', '.', ',', 2)"></td>
The Decimal support is still Work in Progress and was added by accident in the last update. We will revert that change so that the old behavior is back. Depending on the database driver you then get it as Number or as String.
We want to support Decimals because the default JavaScript Number is not very precise. With JavaScript Number 0.3 - 0.1 = 0.19999999999999998
and with Decimal 0.3 - 0.1 = 0.2
.
MikeMcl/decimal.js: An arbitrary-precision Decimal type for JavaScript (github.com)
To recognize the number as a decimal in expressions we will use the m
as a suffix. We also support BigInt with the n
as suffix.
An inline update has been released, it reverts the old behavior back, so no m
will be added to the values.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.