Do not return number of affected rows in Delete*() methods.
This commit is contained in:
parent
bea8df31cb
commit
9347a16fca
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user