-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
100 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
package sqlmock | ||
|
||
import ( | ||
"database/sql/driver" | ||
) | ||
|
||
// Result satisfies sql driver Result, which | ||
// holds last insert id and rows affected | ||
// by Exec queries | ||
type Result struct { | ||
lastInsertId int64 | ||
type result struct { | ||
insertID int64 | ||
rowsAffected int64 | ||
} | ||
|
||
// Creates a new Result for Exec based query mocks | ||
func NewResult(lastInsertId int64, rowsAffected int64) *Result { | ||
return &Result{ | ||
lastInsertId, | ||
// NewResult creates a new sql driver Result | ||
// for Exec based query mocks. | ||
func NewResult(lastInsertID int64, rowsAffected int64) driver.Result { | ||
return &result{ | ||
lastInsertID, | ||
rowsAffected, | ||
} | ||
} | ||
|
||
// Retrieve last inserted id | ||
func (res *Result) LastInsertId() (int64, error) { | ||
return res.lastInsertId, nil | ||
func (r *result) LastInsertId() (int64, error) { | ||
return r.insertID, nil | ||
} | ||
|
||
// Retrieve number rows affected | ||
func (res *Result) RowsAffected() (int64, error) { | ||
return res.rowsAffected, nil | ||
func (r *result) RowsAffected() (int64, error) { | ||
return r.rowsAffected, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.