From 1a3ddb12843eaacca2a6109333331f92eee2603c Mon Sep 17 00:00:00 2001 From: keiser Date: Fri, 4 Nov 2016 18:15:34 +0100 Subject: Ich bin halt einfach der Beste diff --git a/modules/lists/lists.go b/modules/lists/lists.go index c699271..455c39c 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go @@ -695,7 +695,7 @@ func (m *Module) removeGrilFromList(w http.ResponseWriter, r *http.Request, p ht return } - err = m.g.DB.QueryRow(`DELETE FROM grilist.lists_grils WHERE list_id=$1 AND gril_id=$2`, listID, grilID).Scan(&oldOrder) + err = m.g.DB.QueryRow(`DELETE FROM grilist.lists_grils WHERE list_id=$1 AND gril_id=$2 RETURNING "order"`, listID, grilID).Scan(&oldOrder) if err != nil { log.Println("error removing gril:", err) http.Error(w, "could not remove gril", 500) @@ -708,6 +708,12 @@ func (m *Module) removeGrilFromList(w http.ResponseWriter, r *http.Request, p ht http.Error(w, "could not remove gril", 500) return } + + if r, err := res.RowsAffected(); err != nil || r == 0 { + log.Println("invalid rows affected in removing gril") + http.Error(w, "gril not in list / other error", 500) + return + } list.Grils = list.Grils[:0] -- cgit v0.10.1