Skip to content

treat bigint as string in msnodesqlv8 driver#1387

Merged
dhensby merged 1 commit intotediousjs:masterfrom
dhensby:pulls/bigint-msnodesql
Apr 15, 2026
Merged

treat bigint as string in msnodesqlv8 driver#1387
dhensby merged 1 commit intotediousjs:masterfrom
dhensby:pulls/bigint-msnodesql

Conversation

@dhensby
Copy link
Copy Markdown
Collaborator

@dhensby dhensby commented Apr 19, 2022

What this does:

BigInts should be treated as strings to ensure no precision loss

Related issues:

Attempt to fix #1385

Pre/Post merge checklist:

  • Update change log

@dhensby
Copy link
Copy Markdown
Collaborator Author

dhensby commented Apr 19, 2022

Well, interestingly, the tedious driver does not allow strings to be used for bigints and instead they must be set to varchars...

@blitzmann
Copy link
Copy Markdown
Contributor

Would there be an argument for using JS's BitInt type instead of a string? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt

mssql doesn't support Node versions < 10 according to changelog, and it's been around since 10.4

@dhensby
Copy link
Copy Markdown
Collaborator Author

dhensby commented Apr 21, 2022

Yep, definitely, but it's more about the underlying drivers than about this library. If they support either strings and/or BigInt, then we can use them.

@blitzmann
Copy link
Copy Markdown
Contributor

Ah that makes sense

@dhensby dhensby force-pushed the pulls/bigint-msnodesql branch 3 times, most recently from a7527cd to 5c27016 Compare April 28, 2022 21:07
@dhensby dhensby force-pushed the pulls/bigint-msnodesql branch from 5c27016 to e5b3f60 Compare August 19, 2022 08:52
@dhensby dhensby force-pushed the pulls/bigint-msnodesql branch from e5b3f60 to bd791d4 Compare September 4, 2023 22:26
@dhensby
Copy link
Copy Markdown
Collaborator Author

dhensby commented Sep 4, 2023

Well, interestingly, the tedious driver does not allow strings to be used for bigints and instead they must be set to varchars...

So this is the problem we have getting this merged, the tedious driver is the blocker

@dhensby dhensby force-pushed the pulls/bigint-msnodesql branch from bd791d4 to a8723fb Compare September 14, 2023 21:10
@dhensby
Copy link
Copy Markdown
Collaborator Author

dhensby commented Jun 18, 2024

So tedious introduced using native bigints for the bigint type in v18.2.0, which will be added in the next major release of this lib (imminent)

@dhensby dhensby force-pushed the pulls/bigint-msnodesql branch 2 times, most recently from 02f6c66 to 6808162 Compare April 14, 2026 23:45
BigInt types will lose precision if they are above the MAX_SAFE_INTEGER
value. A work around for this is to use strings to represent the numbers
instead.
@dhensby dhensby force-pushed the pulls/bigint-msnodesql branch from 6808162 to 9541bb8 Compare April 15, 2026 00:13
@dhensby dhensby merged commit 99f5c7f into tediousjs:master Apr 15, 2026
47 checks passed
@dhensby dhensby deleted the pulls/bigint-msnodesql branch April 15, 2026 00:48
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 12.2.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigInt incorrectly cast to int with msnodesqlv8

2 participants