Refactor subscriber delete query to support UUIDs

This commit is contained in:
Kailash Nadh 2019-07-20 12:54:30 +05:30
parent 7d9758c3f5
commit 81fe874ee7
2 changed files with 3 additions and 3 deletions

View file

@ -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 (

View file

@ -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))
}