Skip to content

if number length > 15 Error number returned #1476

Answered by sidorares
thankdepend asked this question in Q&A
Discussion options

You must be logged in to vote

This is likely expected behaviour, we map numeric types to a JS number and you can't have precise integer larger than Number.MAX_SAFE_INTEGER - see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

In your case possible solutions are:

  • don't use number for user_id and use string type instead. Note that there are lots of other ways large integer id can bite you ( for example, you'll likely have data corruptions serialising / deserialising id to a JSON )
  • pass supportBigNumbers option:

Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be always returned as JavaScript String objects …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sidorares
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants