Created
April 11, 2019 12:59
-
-
Save chasers/603ac0eaa6b1c25ceaa617f6a65f8587 to your computer and use it in GitHub Desktop.
Deep Merge Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Logflare.DeepMergeTest do | |
# this works: DeepMerge.deep_merge(%{a: %{b: 1}, c: [d: 1]}, %{a: %{z: 5}, c: [x: 0]}) | |
def merge() do | |
DeepMerge.deep_merge(newschema().fields, oldschema().fields) | |
end | |
def newschema do | |
%{ | |
fields: [ | |
%{a: "one", fields: nil}, | |
%{b: "two", fields: nil}, | |
%{ | |
c: "three", | |
fields: [ | |
%{aa: "one one", fields: nil}, | |
%{bb: "two two", fields: nil}, | |
%{ | |
cc: "three, three", | |
fields: [ | |
%{aaa: "one one one", fields: nil} | |
] | |
}, | |
%{dd: "four four", fields: nil} | |
] | |
} | |
] | |
} | |
end | |
def oldschema do | |
%{ | |
fields: [ | |
%{a: "one", fields: nil}, | |
%{ | |
c: "three", | |
fields: [ | |
%{aa: "one one", fields: nil}, | |
%{bb: "two two", fields: nil}, | |
%{ | |
cc: "three, three", | |
fields: [ | |
%{aaa: "one one one", fields: nil}, | |
%{bbb: "two two two", fields: nil}, | |
%{ccc: "three three three", fields: nil} | |
] | |
} | |
] | |
} | |
] | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment