From 00ae8968f7e7c89aac87d300b615a786b4c57221 Mon Sep 17 00:00:00 2001 From: jeffgrunewald Date: Tue, 14 Apr 2020 20:28:44 -0400 Subject: [PATCH] deletes are idempotent --- README.md | 2 +- lib/brook/storage/postgres/query.ex | 2 +- mix.exs | 2 +- test/brook/storage/postgres_test.exs | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c745710..dba8ede 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/lib/brook/storage/postgres/query.ex b/lib/brook/storage/postgres/query.ex index f78cea6..3067925 100644 --- a/lib/brook/storage/postgres/query.ex +++ b/lib/brook/storage/postgres/query.ex @@ -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 diff --git a/mix.exs b/mix.exs index 41d2352..04946f7 100644 --- a/mix.exs +++ b/mix.exs @@ -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(), diff --git a/test/brook/storage/postgres_test.exs b/test/brook/storage/postgres_test.exs index 9f193ef..60ffe84 100644 --- a/test/brook/storage/postgres_test.exs +++ b/test/brook/storage/postgres_test.exs @@ -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