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

Use json-bigint for Integer Parsing #920

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ItzNotABug
Copy link
Contributor

@ItzNotABug ItzNotABug commented Jul 27, 2024

What does this PR do?

Fixes the issue where the big integers are incorrect due to precision loss.

Fixes appwrite/console#1473

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

Yes

@stnguyen90
Copy link
Contributor

@TorstenDittmann, you okay with taking this approach?

@loks0n
Copy link
Member

loks0n commented Sep 3, 2024

Can you share more about the issue? What situation does it occur?

"tsup": "7.2.0",
"esbuild-plugin-file-path-extensions": "^2.0.0",
"tslib": "2.6.2",
"typescript": "5.4.2"
},
"dependencies": {
"json-bigint": "^1.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a depencdency? is it possible without?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. I don't think there's a built-in logic for managing big-ints.

@ItzNotABug
Copy link
Contributor Author

Can you share more about the issue? What situation does it occur?

The values returned on console are different for min/max due to how PHP and JS round off the int/big int. Values should be -
-9223372036854775808 & 9223372036854775807 but JS rounds off to -9223372036854776000 and -9223372036854776000. This causes issues during updates iirc.

@ivanskodje
Copy link

Fixes the issue where the big integers are incorrect due to precision loss.

Does these changes affect how the Console repo parses the number it receives from the backend? I ask, because in Console we are already receiving the correct number from the backend via JSON - but it is only after it parses it into a number object it gets rounded to an incorrect amount causing this issue.

Ref: appwrite/console#1473

@loks0n
Copy link
Member

loks0n commented Nov 26, 2024

Fixes the issue where the big integers are incorrect due to precision loss.

Does these changes affect how the Console repo parses the number it receives from the backend? I ask, because in Console we are already receiving the correct number from the backend via JSON - but it is only after it parses it into a number object it gets rounded to an incorrect amount causing this issue.

Ref: appwrite/console#1473

Yeah, the console SDK is generated using the web sdk with a few extra endpoints

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