bravius commented on issue #236:
URL: https://github.com/apache/age/issues/236#issuecomment-1164973950

   @jasperblues 
   
   _"When is serialization an issue?"_
   
   I believe this demonstrates the problem.
   
   In pgsql generate two graphids with a label id of 64 and entry ids of 1 and 
2:
   
   ```
   SELECT _graphid(64,1), _graphid(64,2); // 18014398509481985, 
18014398509481986
   ```
   
   Then in JavaScript compare the two values:
   
   ```
   console.log( 18014398509481985 == 18014398509481986 ); // true
   ```
   
   Gasp... JavaScript thinks the two graphids are equal. This is because 
JavaScript Number type starts losing precision after 2^53-1.
   
   Now stringify/parse the two values and compare:
   
   ```
   let array = JSON.parse(JSON.stringify([18014398509481985, 
18014398509481986]));
   console.log(array[0] ==  array[1]); // true
   ```
   
   Same issue, JavaScript thinks the two distinct graphids are equal.
   
   BigInt solves the problem of precision loss, but the standard 
JSON.stringify/JSON.parse are not compatible with BigInt and require the use of 
custom replacer/reviver functions on both the client and server. 
   
   _"What envs might need a polyfil?"_
   
   About 90% of browsers are supported. 
   
   https://caniuse.com/bigint
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to