1
0

Do not return number of affected rows in Delete*() methods.

This commit is contained in:
Alexander Andreev 2023-05-06 22:20:11 +04:00
parent bea8df31cb
commit 9347a16fca
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

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