1
0
mirror of https://github.com/DATA-DOG/go-sqlmock.git synced 2025-01-24 03:16:17 +02:00
go-sqlmock/result.go

28 lines
601 B
Go
Raw Normal View History

2014-02-05 16:21:07 +02:00
package sqlmock
2014-02-07 08:58:27 +02:00
// a structure which implements database/sql/driver.Result
// holds last insert id and rows affected
// should be returned by Exec queries
2014-02-05 16:21:07 +02:00
type Result struct {
lastInsertId int64
rowsAffected int64
}
2014-02-07 08:58:27 +02:00
// creates a new result for Exec based query mocks
2014-02-05 16:21:07 +02:00
func NewResult(lastInsertId int64, rowsAffected int64) *Result {
return &Result{
lastInsertId,
rowsAffected,
}
}
2014-02-07 08:58:27 +02:00
// get last insert id
2014-02-05 16:21:07 +02:00
func (res *Result) LastInsertId() (int64, error) {
return res.lastInsertId, nil
}
2014-02-07 08:58:27 +02:00
// get rows affected
2014-02-05 16:21:07 +02:00
func (res *Result) RowsAffected() (int64, error) {
return res.rowsAffected, nil
}