-
Notifications
You must be signed in to change notification settings - Fork 2
/
result.go
48 lines (44 loc) · 898 Bytes
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package sq
import (
"database/sql"
xerr "github.com/goclub/error"
)
type Result struct {
core sql.Result
}
func (r Result) LastInsertId() (id int64, err error) {
id, err = r.core.LastInsertId()
if err != nil {
err = xerr.WithStack(err)
return
}
return
}
func (r Result) LastInsertUint64Id() (id uint64, err error) {
var int64id int64
int64id, err = r.LastInsertId()
if err != nil {
return
}
if int64id < 0 {
err = xerr.New("goclub/sql: sq.Result{}.LastInsertUint64Id() (id, err) id less than 0")
return
}
id = uint64(int64id)
return
}
func (r Result) RowsAffected() (rowsAffected int64, err error) {
rowsAffected, err = r.core.RowsAffected()
if err != nil {
err = xerr.WithStack(err)
return
}
return
}
func RowsAffected(result Result, execErr error) (affected int64, err error) {
if execErr != nil {
err = execErr
return
}
return result.RowsAffected()
}