Skip to content

BigInt incorrectly cast to int with msnodesqlv8 #1385

@dsbert

Description

@dsbert

When using the msnodesqlv8 library, values passed into a BigInt column as strings are incorrectly cast using parseInt. This results in an incorrect value.

case TYPES.BigInt:
case TYPES.SmallInt:
if ((typeof value !== 'number') && !(value instanceof Number)) {
value = parseInt(value)
if (isNaN(value)) { value = null }
}
break

For example:

const value = "9223372036854775807";

console.log(value);
// 9223372036854775807

console.log(parseInt(value));
// 9223372036854776000

SQL Server can cast the string to a BIGINT implicitly, so I'm not really sure why a cast is required in the library at all. But no matter what the case, the current logic seems to result in bad data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions