Skip to content
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

Convert bigints that exceed js number limits to strings #109

Merged
merged 3 commits into from
Jan 8, 2016

Conversation

sosedoff
Copy link
Owner

@sosedoff sosedoff commented Jan 7, 2016

Should fix #108

sosedoff added a commit that referenced this pull request Jan 8, 2016
Convert bigints that exceed js number limits to strings
@sosedoff sosedoff merged commit e662e90 into master Jan 8, 2016
@skabbes
Copy link
Contributor

skabbes commented Jan 8, 2016

Thanks so much! Any chance you'll release a 0.7.1 soon?

@sosedoff
Copy link
Owner Author

sosedoff commented Jan 8, 2016

I'll release 0.7.1 in a day or so, working on a few other things that should go in too.

val := col.(int64)
if val < -9007199254740991 || val > 9007199254740991 {
res.Rows[i][j] = strconv.FormatInt(col.(int64), 10)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what its worth, I don't really agree with dynamically changing the shape of the json object based on the values.

For example, consider this code:

while (true) {
    var result = JSON.parse(getValueFromApi());
    var oneHigher = result.usuallyNumber + 1;
    saveToDb({usuallyNumber: oneHigher});
}

If result.usuallyNumber is all of a sudden a string (because your values got too big), the + operator in javascript ends up becoming string concatenation.

1
2
3
...
9007199254740989
9007199254740990
9007199254740991
90071992547409911
900719925474099111
9007199254740991111

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pgweb is not considered to be used as a "real" api. So its api is exposed solely to be consumed by the frontend application.

@skabbes
Copy link
Contributor

skabbes commented Jan 8, 2016

All that said, I'm not going to complain about free software :)

Thanks for you're awesome contribution to the OSS community.

@sosedoff sosedoff deleted the bigint-to-string branch January 10, 2016 22:16
@sosedoff
Copy link
Owner Author

FYI 0.8.0 is published to homebrew cask.

@skabbes
Copy link
Contributor

skabbes commented Jan 11, 2016

Awesome! Muchas gracias, could you push to dockerhub too when you have a chance?

@sosedoff
Copy link
Owner Author

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bigint columns truncated to Javascript limits (52 - 53 bits)
2 participants