Skip to content

Commit

Permalink
deletes are idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgrunewald committed Apr 15, 2020
1 parent 569296b commit 00ae896
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ to your mix.exs file.
```elixir
def deps do
[
{:brook_storage_postgres, "~> 0.1.0"}
{:brook_storage_postgres, "~> 0.1.1"}
]
end
```
Expand Down
2 changes: 1 addition & 1 deletion lib/brook/storage/postgres/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ defmodule Brook.Storage.Postgres.Query do
:ok | {:error, Brook.reason()}
def postgres_delete(conn, view_table, collection, key) do
case Postgrex.query(conn, delete_stmt(view_table), [collection, key]) do
{:ok, %Postgrex.Result{num_rows: 1, rows: nil}} -> :ok
{:ok, %Postgrex.Result{num_rows: rows, rows: nil}} when rows in [0, 1] -> :ok
error_result -> error_result
end
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule BrookStoragePostgres.MixProject do
def project do
[
app: :brook_storage_postgres,
version: "0.1.0",
version: "0.1.1",
elixir: "~> 1.8",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
1 change: 1 addition & 0 deletions test/brook/storage/postgres_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ defmodule Brook.Storage.PostgresTest do
assert {:ok, "value1"} == Postgres.get(@instance, "people", "key1")

:ok = Postgres.delete(@instance, "people", "key1")
assert :ok = Postgres.delete(@instance, "people", "key1")
assert {:ok, nil} == Postgres.get(@instance, "people", "key1")
assert {:ok, []} == Postgres.get_events(@instance, "people", "key1")
end
Expand Down

0 comments on commit 00ae896

Please sign in to comment.