Skip to content

Commit

Permalink
Refactor subscriber delete query to support UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jul 20, 2019
1 parent 7d9758c commit 81fe874
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ INSERT INTO subscriber_lists (subscriber_id, list_id, status)
SET status = (CASE WHEN $4='blacklisted' THEN 'unsubscribed'::subscription_status ELSE 'unconfirmed' END);

-- name: delete-subscribers
-- Delete one or more subscribers.
DELETE FROM subscribers WHERE id = ANY($1);
-- Delete one or more subscribers by ID or UUID.
DELETE FROM subscribers WHERE CASE WHEN ARRAY_LENGTH($1::INT[], 1) > 0 THEN id = ANY($1) ELSE uuid = ANY($2::UUID[]) END;

-- name: blacklist-subscribers
WITH b AS (
Expand Down
2 changes: 1 addition & 1 deletion subscribers.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func handleDeleteSubscribers(c echo.Context) error {
IDs = i
}

if _, err := app.Queries.DeleteSubscribers.Exec(IDs); err != nil {
if _, err := app.Queries.DeleteSubscribers.Exec(IDs, nil); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError,
fmt.Sprintf("Error deleting: %v", err))
}
Expand Down

0 comments on commit 81fe874

Please sign in to comment.