mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-24 14:58:35 +08:00
Fix attribute replacement in storage (#1778)
This commit is contained in:
parent
86ddd68ca0
commit
6e4c81edae
2 changed files with 7 additions and 2 deletions
|
@ -239,8 +239,11 @@ defmodule Livebook.Storage do
|
|||
defp delete_keys(table, namespace, entity_id, keys) do
|
||||
match_head = {{namespace, entity_id}, :"$1", :_, :_}
|
||||
|
||||
guards = Enum.map(keys, &{:==, :"$1", &1})
|
||||
guard =
|
||||
keys
|
||||
|> Enum.map(&{:==, :"$1", &1})
|
||||
|> Enum.reduce(&{:orelse, &1, &2})
|
||||
|
||||
:ets.select_delete(table, [{match_head, guards, [true]}])
|
||||
:ets.select_delete(table, [{match_head, [guard], [true]}])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,6 +33,8 @@ defmodule Livebook.StorageTest do
|
|||
key2: "val2",
|
||||
key3: "val3"
|
||||
}} = Storage.fetch(:insert, "replace")
|
||||
|
||||
assert {:ok, "updated_val1"} = Storage.fetch_key(:insert, "replace", :key1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue