-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
I may have found a bug. I tried replacing diff
by cheapDiff
for efficiency reasons but found out that the json output after applying the patch was not the same.
Here is an example of diverging results:
import Json.Diff as Diff exposing (..)
import Json.Patch.Invertible as Inv exposing (..)
import Json.Encode as E
import Json.Decode as D
import Json.Patch as JP exposing (..)
doc1 = E.list E.int [1,2,3,4]
doc2 = E.list E.int [2,1,3,4]
patch = Diff.diff doc1 doc2
-- [Remove ["1"],Add ["0"] <internals>] : Patch
cheapPatch = Diff.cheapDiff doc1 doc2 |> Inv.toMinimalPatch
-- [Replace ["1"] <internals>] : Patch
JP.apply patch doc1 |> Result.toMaybe |> Maybe.map (D.decodeValue <| D.list D.int)
-- Just (Ok [2,1,3,4])
JP.apply cheapPatch doc1 |> Result.toMaybe |> Maybe.map (D.decodeValue <| D.list D.int)
-- Just (Ok [1,1,3,4]) : Maybe (Result D.Error (List Int))
Metadata
Metadata
Assignees
Labels
No labels