Code Monkey home page Code Monkey logo

Comments (8)

StrikerJS avatar StrikerJS commented on August 22, 2024 1

Wtf u talk m8s kys lel lmao 420

from node-mssql.

rossipedia avatar rossipedia commented on August 22, 2024

Okay, I've found the offending value and it has to do with IEEE 754 rounding errors and how node-tedious handles decimal values with small precision.

The value was 32.343948. The parameter type is a decimal(9, 6). Tedious writes decimals with precision of <= 9 directly to the TDS stream as a single 32-bit integer, and it does so by multiplying the value by 10^scale (the scale is 6 in this case). The code looks like this:

value = Math.abs parameter.value * Math.pow(10, parameter.scale)

The resulting value should be 32343948. However, due to floating point rounding errors, you end up with 32343947.999999996, which causes Buffer.writeUInt32LE to throw an exception.

I believe the short term solution is to just Math.round the value, and I'll be submitting a PR to tedious to address this.

from node-mssql.

roncli avatar roncli commented on August 22, 2024

While you have been able to resolve this specific case, the issue here is that an error is actually being thrown, crashing the app, instead of being passed back into the callback to be handled gracefully. For instance, I accidentally was passing an undefined into an int and getting the same error.

I'll look into doing a pull request for this issue when I have time.

from node-mssql.

Llorx avatar Llorx commented on August 22, 2024

Floating point is now corrected by Tedious, as they now do Math.round()
https://github.com/tediousjs/tedious/blob/50e76efdcd87f687106c722d54c6ea4096f0a127/src/data-type.js#L421

from node-mssql.

elucidsoft avatar elucidsoft commented on August 22, 2024

I still receive this error with decimals...

from node-mssql.

ChristofDC avatar ChristofDC commented on August 22, 2024

make sure you don't mix up precision and scale.
decimal(precision, scale)
When I switched the two I got the out of bounds error

from node-mssql.

CodeMuz avatar CodeMuz commented on August 22, 2024

I get this error on Windows and node v12.13.0, but not Linux or Mac. For example while trying to save the data 1000000.4 into DataTypes.DECIMAL(18,2). The error is from the node library file buffer.js which throws an error crashing the app.

from node-mssql.

dhensby avatar dhensby commented on August 22, 2024

This is (was) and issue with the tedious driver which is now fixed. Please use the latest version of node-mssql if you wish to resolve this issue. locking this thread as resolved

from node-mssql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.