Mike_Z
August 1, 2024, 5:36pm
1
I have a MySQL table. Test data consists of an "Amount’ field, and three rows with values, 1000, My JSON input is:
[
{
"row_number": 2,
"Amount": -1000
},
{
"row_number": 3,
"Amount": -52.23
},
{
"row_number": 4,
"Amount": -71.09
}
]
I have a SQL Select using query parameters.
The output from the SELECT is
[
{
"reccount": 1,
"amount": -1000
},
{
"reccount": 1,
"amount": "-52.23"
},
{
"reccount": 0,
"amount": "-71.09"
}
]
Why is the first record in the output a numeric value, while the other records are strings?
This is the result regardless of whether the query parameter for Amount is modified with .toFixed(2), or if the SELECT statement has CONVERT($1,DECIMAL) . I tried a few other permutations. The SELECT does return the proper COUNT() values, but I need consistent output for subsequent steps.
n8n cloud, version 1.51
Mike
n8n
August 1, 2024, 5:36pm
2
It looks like your topic is missing some important information. Could you provide the following if applicable.
n8n version:
Database (default: SQLite):
n8n EXECUTIONS_PROCESS setting (default: own, main):
Running n8n via (Docker, npm, n8n cloud, desktop app):
Operating system:
ria
August 5, 2024, 4:24pm
4
Hi @Mike_Z
Thanks for posting here!
Looks like we do not capture the DECIMAL
types in MySQL. Let me raise a ticket and get this fixed
Mike_Z
August 5, 2024, 5:58pm
6
Glad it wasn’t something I was doing wrong! Thanks
ria
August 7, 2024, 10:34am
7
Hey @Mike_Z
We got the fix in the pipeline and will probably release next week!
You can then use a toggle option for this
n8n-io:master
← n8n-io:node-1553-mysql-node-decimal-types-are-returned-as-strings
opened 07:58AM - 07 Aug 24 UTC
## Summary
<!--
Describe what the PR does and how to test.
Photos and video… s are recommended.
-->
- adds option to return Decimal values as number format instead of strings
## Related Linear tickets, Github issues, and Community forum posts
- https://linear.app/n8n/issue/NODE-1553/mysql-node-decimal-types-are-returned-as-strings
- https://community.n8n.io/t/mysql-select-and-numbers/51104
<!--
Include links to **Linear ticket** or Github issue or Community forum post.
Important in order to close *automatically* and provide context to reviewers.
-->
## Review / Merge checklist
- [x] PR title and summary are descriptive. ([conventions](../blob/master/.github/pull_request_title_conventions.md)) <!--
**Remember, the title automatically goes into the changelog.
Use `(no-changelog)` otherwise.**
-->
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up ticket created.
- [ ] Tests included. <!--
A bug is not considered fixed, unless a test is added to prevent it from happening again.
A feature is not complete without tests.
-->
- [ ] PR Labeled with `release/backport` (if the PR is an urgent fix that needs to be backported)
1 Like
Hey @ria , I find it odd that we have to be explicit setting decimal as numbers rather than having that option by default. After all decimals are numbers. Is this solution just a workaround and will be (hopefully) “properly” fixed later on?
Jon
August 7, 2024, 6:54pm
9
Hey @ihortom ,
The change put in is not a workaround and is the way to fix this issue, Javascript has a limit when it comes to numbers and the package used returns a decimal as a string so that you don’t lose precision.
This is also why we return large format numbers as strings instead of numbers because of the 16 digit length.
You can read a bit more about this here: API and Configuration | Quickstart
2 Likes
system
Closed
August 14, 2024, 6:54pm
10
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
jan
August 15, 2024, 8:56am
11
New version [email protected]
got released which includes the GitHub PR 10313 .