From 9347a16fca8078899b79f675dc16686705299a32 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 6 May 2023 22:20:11 +0400 Subject: [PATCH] Do not return number of affected rows in Delete*() methods. --- database/sqlite/database.go | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/database/sqlite/database.go b/database/sqlite/database.go index efe1451..c0a832a 100644 --- a/database/sqlite/database.go +++ b/database/sqlite/database.go @@ -221,26 +221,20 @@ func (d *SQLiteDatabase) EditEntry(entry *guestbook.Entry) error { return nil } -func (d *SQLiteDatabase) DeleteEntry(entryID int64) (int64, error) { +func (d *SQLiteDatabase) DeleteEntry(entryID int64) error { tx, err := d.db.Begin() if err != nil { - return -1, err + return err } defer tx.Rollback() - res, err := tx.Stmt(stmtDeleteEntry).Exec(entryID) - if err != nil { - return -1, err - } - - c, err := res.RowsAffected() - if err != nil { - return -1, err + if _, err = tx.Stmt(stmtDeleteEntry).Exec(entryID); err != nil { + return err } tx.Commit() - return c, nil + return nil } func (d *SQLiteDatabase) NewReply(reply *guestbook.Reply) error { @@ -278,26 +272,20 @@ func (d *SQLiteDatabase) EditReply(reply *guestbook.Reply) error { return nil } -func (d *SQLiteDatabase) DeleteReply(entryID int64) (int64, error) { +func (d *SQLiteDatabase) DeleteReply(entryID int64) error { tx, err := d.db.Begin() if err != nil { - return -1, err + return err } defer tx.Rollback() - res, err := tx.Stmt(stmtDeleteReply).Exec(entryID) - if err != nil { - return -1, err - } - - ra, err := res.RowsAffected() - if err != nil { - return -1, err + if _, err = tx.Stmt(stmtDeleteReply).Exec(entryID); err != nil { + return err } tx.Commit() - return ra, nil + return nil } func (d *SQLiteDatabase) Close() error {