-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reexamine BIGINT returning strings #2398
Comments
Related, from 5 days ago - #2395 This however idea is the opposite. We do not need native It is the use of |
See brianc/node-pg-types#78 for existing discussion about this.
That’s not very reassuring, but the difference between the existing string behaviour and Anyway, the rest of my comment is also in that issue: brianc/node-pg-types#78 (comment). |
@vitaly-t Today you are returning strings, so you still don't lose precision, given that I don't understand the "precision is not needed" argument. (Also, if I picked BigInt as my datatype, it potentially means I do want the extra precision.) @charmander From what I gather from the linked issue, there's a general consensus that it's a positive change (also I'm not sure why browsers are discussed there), is there anything else blocking it? |
Most developers opt to parse 64-bit numbers as type.setTypeParser(20, a => parseInt(a)); |
That's fair, if you want to do any sort of math on it whatsoever, it has to be a number of some sort. Also, I suspect that not many developers today are even aware of the existence of BigInt in the language, it's kind of an obscure feature. |
@MadaraUchiha A plan to reduce the number of surprising bugs people run into while upgrading to pg 9.x, or agreement that no such plan is necessary. The default change can probably go into pg-types right now, since that package is already accumulating breaking changes for its next major version. |
This should be closed, because even today, |
@vitaly-t The current default is strings, not numbers, and correct/surprise-free behaviour is more important than small and avoidable performance differences anyway. |
Related: #353
Back in 2013 this was a good idea, as BIGINTs would lose precision when converted to JavaScript numbers (which are doubles).
Today we have native BigInt support in JavaScript, can we reconsider returning/accepting BigInts when doing database operations with the BIGINT type?
Pros and cons as far as I can tell:
Pros:
Cons:
Thoughts?
The text was updated successfully, but these errors were encountered: