2014-02-05 17:21:07 +03:00
|
|
|
package sqlmock
|
|
|
|
|
2014-02-08 18:51:58 +03:00
|
|
|
import (
|
2014-02-13 22:59:35 +03:00
|
|
|
"database/sql/driver"
|
2014-02-08 18:51:58 +03:00
|
|
|
)
|
|
|
|
|
2014-02-07 11:44:41 +03:00
|
|
|
// Result satisfies sql driver Result, which
|
2014-02-07 09:58:27 +03:00
|
|
|
// holds last insert id and rows affected
|
2014-02-07 11:44:41 +03:00
|
|
|
// by Exec queries
|
2014-02-08 18:51:58 +03:00
|
|
|
type result struct {
|
2014-02-13 22:59:35 +03:00
|
|
|
insertID int64
|
2014-02-05 17:21:07 +03:00
|
|
|
rowsAffected int64
|
|
|
|
}
|
|
|
|
|
2014-02-08 18:51:58 +03:00
|
|
|
// NewResult creates a new sql driver Result
|
|
|
|
// for Exec based query mocks.
|
|
|
|
func NewResult(lastInsertID int64, rowsAffected int64) driver.Result {
|
|
|
|
return &result{
|
|
|
|
lastInsertID,
|
2014-02-05 17:21:07 +03:00
|
|
|
rowsAffected,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-08 18:51:58 +03:00
|
|
|
func (r *result) LastInsertId() (int64, error) {
|
|
|
|
return r.insertID, nil
|
2014-02-05 17:21:07 +03:00
|
|
|
}
|
|
|
|
|
2014-02-08 18:51:58 +03:00
|
|
|
func (r *result) RowsAffected() (int64, error) {
|
|
|
|
return r.rowsAffected, nil
|
2014-02-05 17:21:07 +03:00
|
|
|
}
|