surrealdb / surrealdb.js

SurrealDB SDK for JavaScript
https://surrealdb.com
Apache License 2.0
294 stars 48 forks source link

Bug: Error when serializing BigInt #204

Closed Fleny113 closed 5 months ago

Fleny113 commented 9 months ago

Describe the bug

When creating a record with as a value a BigInt the JSON.stringify in the send method of the WebSocketStrategy class errors with the following error: TypeError: JSON.stringify cannot serialize BigInt.. Making it impossible to store numbers that need to be BigInt, or else they would get truncated by JS, in the SurrealDB instance.

Also all values retrived by the database also get truncated for the exact same reason

Steps to reproduce

For TypeError: JSON.stringify cannot serialize BigInt.:

For the truncated number received:

Expected behaviour

For the error: the error doesn't get throw and the value is inserted into the database.

For the truncated values: the value is not truncated

SurrealDB version

surreal 1.0.2 for linux on x86_64

SurrealDB.js version

0.11.0

Contact Details

No response

Is there an existing issue for this?

Code of Conduct

kearfy commented 5 months ago

This should be resolved by #227