Skip to content

43069.0122916667 value will not be written correctly to mssql #11959

Closed

Description

@JohnOnLee

Issue Description

43069.0122916667 value will not be written correctly to mssql

What are you doing?

const value = 43069.0122916667;
getSQLTypeFromJsType(value, connection.lib.TYPES);

What do you expect to happen?

For the value '43069.0122916667', it ended up written '6175.5241442476'

What is actually happening?

when 43069.0122916667 is passed to getSQLTypeFromJsType, the precision and scale will be set to 30 and 15.
Which in tedios isn't handled correctly.
see issue tediousjs/tedious#1058

Additional context

tediousjs/tedious#1058

Environment

  • Sequelize version: 5.21.5
  • Node.js version: v10.16.0
  • Operating System: osx 10.14.6

Issue Template Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s): mssql
  • I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

Activity

  1. papb commented on Mar 17, 2020

    @papb
    Member

    Hello, thanks for filing the issue and writing a PR! It is not clear to me however if your PR #11962 fixed your problem entirely or just part of it.

    Is the problem solved? Can this issue be closed? Thanks

  2. added
    status: awaiting response
    on Mar 17, 2020
  3. JohnOnLee commented on Mar 17, 2020

    @JohnOnLee
    ContributorAuthor

    Hi @papb
    for now, it will fix the issue. Ideally, we also want to set a correct precision value as per the comment in the code.

    //Default to a reasonable numeric precision/scale pending more sophisticated logic

  4. papb commented on Mar 17, 2020

    @papb
    Member

    Nice! Do you have any idea on how to set the correct precision?

  5. papb commented on Mar 17, 2020

    @papb
    Member

    Closed by #11962

  6. added
    dialect: mssql
    type: bug
    and removed
    status: awaiting response
    on Mar 17, 2020
  7. JohnOnLee commented on Mar 18, 2020

    @JohnOnLee
    ContributorAuthor

    I might need to have a look to figure that out.

  8. papb commented on Mar 18, 2020

    @papb
    Member

    @MartinJLee if you could do that it would be great! No need to go deep into it, just give me some direction... For instance, currently the precision is set to a constant (30). What it should depend on?

  9. JohnOnLee commented on Mar 18, 2020

    @JohnOnLee
    ContributorAuthor

    @papb You can find the detail in the following link
    https://docs.microsoft.com/en-us/sql/t-sql/data-types/precision-scale-and-length-transact-sql?view=sql-server-ver15

    Precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in a number. For example, the number 123.45 has a precision of 5 and a scale of 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dialect: mssqltype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions