-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.go
49 lines (39 loc) · 1.09 KB
/
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
49
package pqxd
import "database/sql/driver"
// compatibility checks
var (
_ driver.Result = (*pqxdResult)(nil)
)
// pqxdResult is an implementation of driver.Result
type pqxdResult struct {
// affected is the number of rows affected
affected int64
}
// LastInsertId See: driver.Result
func (r pqxdResult) LastInsertId() (int64, error) {
return 0, ErrNotSupported
}
// RowsAffected See: driver.Result
func (r pqxdResult) RowsAffected() (int64, error) {
return r.affected, nil
}
// newPqxdResult returns new pqxdResult
func newPqxdResult(affected int64) *pqxdResult {
return &pqxdResult{affected: affected}
}
// lazyResult is resolve the affected rows lazily
type lazyResult struct {
getAffected func() (int64, error)
}
// LastInsertId See: driver.Result
func (r lazyResult) LastInsertId() (int64, error) {
return 0, ErrNotSupported
}
// RowsAffected See: driver.Result
func (r lazyResult) RowsAffected() (int64, error) {
return r.getAffected()
}
// newLazyResult returns new lazyResult
func newLazyResult(getAffected func() (int64, error)) driver.Result {
return lazyResult{getAffected: getAffected}
}