rocicorp / replicache

Realtime Sync for Any Backend Stack
https://doc.replicache.dev
1.02k stars 37 forks source link

Redo sample app: order number is getting serialized weirdly #148

Closed aboodman closed 3 years ago

aboodman commented 4 years ago
22:58:20.698390 repm.go:64: <-- 200 http://localhost:7001/pull {"stateID":"ia2puj0gebgdvj6u367r3a1q52gvu361","lastMutationID":0,"patch":[{"op":"remove","path":"/"},{"op":"add","path":"/~1list~129395","value":{"id":29395,"ownerUserID":3}},{"op":"add","path":"/~1todo~11717351655","value":{"complete":false,"id":1717351655,"listId":29395,"order":89884656743115790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,"text":"todo one"}}],"checksum":"35478836","clientViewInfo":{"httpStatusCode":200,"errorMessage":""}}
arv commented 4 years ago

This is part of the spec. http://gibson042.github.io/canonicaljson-spec/

  1. MUST represent all integer numbers (those with a zero-valued fractional part)
    1. without a leading minus sign when the value is zero, and
    2. without a decimal point, and
    3. without an exponent, and
    4. without insignificant leading zeroes (as already required of all JSON numbers)
arv commented 4 years ago

We can and probably should do what Figma did and use a big num under the hood and encode it using base96.

A better impl is outlined here https://observablehq.com/@dgreensp/implementing-fractional-indexing

arv commented 4 years ago

We really need to change because our current model runs out of precision pretty fast

aboodman commented 4 years ago

That's a long article :). Agree that this is what we should do.

On Tue, May 12, 2020 at 6:58 AM Erik Arvidsson notifications@github.com wrote:

We really need to change because our current model runs out of precision pretty fast

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rocicorp/replicache/issues/55#issuecomment-627468221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATUBBWZE45LHRDKWDP2YLRRF5Z5ANCNFSM4M6UHMUQ .

aboodman commented 3 years ago

This issue exists in both lit-todo demo too.

arv commented 3 years ago

Let's just fix this and create an npm repo

arv commented 3 years ago

Fixed with 8da53e8c655dddc7dbaf847a286c684c41f39289