Closed UwUDev closed 4 months ago
The issue seems to come fromJSON.parse()
Maybe there is a better lib to parse json in TS
EDIT: using bigint seems to fix it
function reviver(key, value) {
if (typeof value === 'string') {
if (/^\d+$/.test(value)) {
return BigInt(value);
}
}
return value;
}
const parsed = JSON.parse(jsonString, reviver);
This is an extremely tricky issue to solve, as even revivers won't result in the correct outcome (See https://jsoneditoronline.org/indepth/parse/why-does-json-parse-corrupt-large-numbers/).
I'll continue to investigate possible solutions for this issue though.
This has now been resolved in Surrealist 2.0 when previewing responses in SurrealQL, as unlike JSON, SurrealQL does support 64-bit numbers.
We are still rolling this out to other editors throughout Surrealist in the coming releases
Describe the bug Large numbers (i guess above an u32) get their last decimal floored to 0
Edit: Sometime it can be more than one decimal
To Reproduce Steps to reproduce the behavior:
574317759736053768
select test_column from test_table
574317759736053760
instead of574317759736053768
Expected behavior Get the right number
Environment (you can view the current version under Settings):
SurrealDB Version : 1.1.1
Example Expected response:
Got:
You can also see that sometimes the last two decimals got floored