fix attemps to merge map
This commit is contained in:
parent
23decaab81
commit
e1603ac8fe
|
@ -135,7 +135,8 @@ def update_or_create(params) do
|
||||||
|
|
||||||
with %ConfigDB{} = config <- ConfigDB.get_by_params(search_opts),
|
with %ConfigDB{} = config <- ConfigDB.get_by_params(search_opts),
|
||||||
{_, true, config} <- {:partial_update, can_be_partially_updated?(config), config},
|
{_, true, config} <- {:partial_update, can_be_partially_updated?(config), config},
|
||||||
{_, true, config} <- {:can_be_merged, is_list(params[:value]), config} do
|
{_, true, config} <-
|
||||||
|
{:can_be_merged, is_list(params[:value]) and is_list(config.value), config} do
|
||||||
new_value = merge_group(config.group, config.key, config.value, params[:value])
|
new_value = merge_group(config.group, config.key, config.value, params[:value])
|
||||||
update(config, %{value: new_value})
|
update(config, %{value: new_value})
|
||||||
else
|
else
|
||||||
|
|
|
@ -43,7 +43,7 @@ test "common" do
|
||||||
|
|
||||||
params = [
|
params = [
|
||||||
%{group: :pleroma, key: key2, value: "another_value"},
|
%{group: :pleroma, key: key2, value: "another_value"},
|
||||||
%{group: :pleroma, key: config.key, value: "new_value"}
|
%{group: :pleroma, key: config.key, value: [a: 1, b: 2, c: "new_value"]}
|
||||||
]
|
]
|
||||||
|
|
||||||
assert Repo.all(ConfigDB) |> length() == 1
|
assert Repo.all(ConfigDB) |> length() == 1
|
||||||
|
@ -55,7 +55,7 @@ test "common" do
|
||||||
config1 = ConfigDB.get_by_params(%{group: config.group, key: config.key})
|
config1 = ConfigDB.get_by_params(%{group: config.group, key: config.key})
|
||||||
config2 = ConfigDB.get_by_params(%{group: :pleroma, key: key2})
|
config2 = ConfigDB.get_by_params(%{group: :pleroma, key: key2})
|
||||||
|
|
||||||
assert config1.value == "new_value"
|
assert config1.value == [a: 1, b: 2, c: "new_value"]
|
||||||
assert config2.value == "another_value"
|
assert config2.value == "another_value"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -398,6 +398,10 @@ test "keyword" do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "trandformed keyword" do
|
||||||
|
assert ConfigDB.to_elixir_types(a: 1, b: 2, c: "string") == [a: 1, b: 2, c: "string"]
|
||||||
|
end
|
||||||
|
|
||||||
test "complex keyword with nested mixed childs" do
|
test "complex keyword with nested mixed childs" do
|
||||||
assert ConfigDB.to_elixir_types([
|
assert ConfigDB.to_elixir_types([
|
||||||
%{"tuple" => [":uploader", "Pleroma.Uploaders.Local"]},
|
%{"tuple" => [":uploader", "Pleroma.Uploaders.Local"]},
|
||||||
|
|
Loading…
Reference in New Issue