archfirst/joinjs

Numeric values being parsed as string

compleatguru opened this issue · 2 comments

I find that the mapping function injectResultInObject()
has mapped some numeric values as string, which is undesirable for me.

I had solved by doing below (line 139-142)

index.txt

        var value = result[columnPrefix+column];
        value = !isNaN(value) && typeof value !=="undefined" && value !== "" ? Number(value):value;

Hope you can consider this fix.

Can you please provide a test for this? I tried the following in a test where I expect a number and found that I did get a number.

expect(mappedResult[0].orders[0].total).to.be.a('number');

Also are you sure that your database driver is returning a number for a numeric type. For example, I use postgres and I had to use pg-parse-float to get decimal numbers back as floats. So check the field returned in your resultset.

No response - closing.