dmxAppConnect.js:6 Method "formatCurrency" not found in expression

Wappler Version : 6.5.0
Server Model: Node/Docker
Database Type: MySQL
Hosting Type: Digital Ocean Droplet

Just noticed everywhere (and we have hundreds) we have used a formatter on a number for currency (stored in database as decimal) we are seeing this error. Despite it being in the database as a decimal we have to format to number to alleviate the error?

Narrowed it down to the database driver. Reverted database connection driver to depreciated and all good. Obviously update to remote for MySQL 2 package for Node did not apply. Will work on it…

How did you got to the mysql2 driver in first place and wasn’t it added to that package.json automatically?

Very weird all fine local but remote just will not display the formatter correctly unless using the depreciated MySQL driver. Restarted the application, rebooted the server, checked everything and all matches the same as locally.

Added fine George, local all good, remote not so good. Will have a bite to eat and try to wrap my head around it.

Cleaned up packages, updated packages, removed all containers, re-booted server, re-deployed and all seems fine and working now George. No errors.

Thank you for the prompt response though!

:slight_smile:

1 Like

That’s an exemplar use of bold! :man_teacher:

3 Likes

It’s the London Look! :smiley:

1 Like

Would like to re-submit this as a bug report. The solution I posted previously did not resolve the issue.

We added a new database connection and the currency formatting persists despite MySQL2 being included.

The value is stored in the database as:

DECIMAL(10,2)

The value is recognised as a number by Wappler’s Expression Builder. We then apply the Currency Formatter to the value as such:

accountAmount.formatCurrency(‘€’, ‘.’, ‘,’, 2)

This works fine with the depreciated driver but with the new driver:

Please could you try and replicate this @George?

Reverting back to the depreciated driver resolves it. This is the only issue we have with the MySQL2 package.

Side note - If you apply Convert to Number and then the Currency Formatter it displays fine. Which suggests it is a bug.

Much appreciated! Await to hear your response.

The MySQL2 driver return DECIMAL type as a string and formatCurrency only is for numbers. This is the only difference with the MySQL driver.

API and Configuration | Quickstart (sidorares.github.io)

There is no equivalent for DECIMAL in JavaScript, depending on the database driver the value is converted into a Number or a String. The Number type in JavaScript is a float and doesn’t have the same precision as the DECIMAL type of the database have and can cause data loss, so many database drivers return the value as a string instead.

1 Like

Appreciated @patrick at least that explains it. I’m not going to moan that it has been the standard for years to store as decimal (intentional oxymoron). Won’t change anything. Adapt and survive.

Backed up and used Wappler’s super powerful search and replace.

Find all .formatCurrency(‘€’, ‘.’, ‘,’, 2)}}

Replace all .toNumber().formatCurrency(‘€’, ‘.’, ‘,’, 2)}}

Deployed locally and will now begin checking a couple of hundred pages for errors…

:wink:

1 Like

Sorry @patrick, one more thing.

Could you guys disable decimals from having the ability to have currency formatting applied to them (without first being converted to number of course) within the Expression Builder?

1 Like

Maybe we should just allow the formatCurrency to be applied also on strings - and then in case of string threat it as a decimal? @patrick

2 Likes