-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.go
More file actions
33 lines (28 loc) · 743 Bytes
/
util.go
File metadata and controls
33 lines (28 loc) · 743 Bytes
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
package db
import (
"database/sql"
"io"
)
type Result sql.Result
type Row interface {
Scan(dest ...interface{}) error
}
type Rows interface {
io.Closer
Scan(dest ...interface{}) error
Next() bool
Err() error
Columns() ([]string, error)
}
// ExpectRowsAffected returns whether RowsAffected() succeeded, and an error if the count was not as expected.
func ExpectRowsAffected(res Result, countExpected int64, errIfNot error) (bool, error) {
count, err := res.RowsAffected()
if err != nil {
// Something happened, but perhaps the operation went through.
// Should we care? Probably not, but return false so the caller knows.
return false, nil
} else if count != countExpected {
return true, errIfNot
}
return true, nil
}