|
5 | 5 | "database/sql/driver"
|
6 | 6 | "errors"
|
7 | 7 | "fmt"
|
8 |
| - |
9 | 8 | "io/ioutil"
|
10 | 9 | "path/filepath"
|
11 | 10 | "reflect"
|
@@ -51,9 +50,9 @@ func mapper() *reflectx.Mapper {
|
51 | 50 |
|
52 | 51 | // isScannable takes the reflect.Type and the actual dest value and returns
|
53 | 52 | // whether or not it's Scannable. Something is scannable if:
|
54 |
| -// * it is not a struct |
55 |
| -// * it implements sql.Scanner |
56 |
| -// * it has no exported fields |
| 53 | +// - it is not a struct |
| 54 | +// - it implements sql.Scanner |
| 55 | +// - it has no exported fields |
57 | 56 | func isScannable(t reflect.Type) bool {
|
58 | 57 | if reflect.PtrTo(t).Implements(_scannerInterface) {
|
59 | 58 | return true
|
@@ -633,6 +632,17 @@ func (r *Rows) StructScan(dest interface{}) error {
|
633 | 632 | return r.Err()
|
634 | 633 | }
|
635 | 634 |
|
| 635 | +// NextResultSet behaves like sql.NextResultSet, but cleans cache of previous result set. |
| 636 | +func (r *Rows) NextResultSet() bool { |
| 637 | + if !r.Rows.NextResultSet() { |
| 638 | + return false |
| 639 | + } |
| 640 | + r.started = false |
| 641 | + r.fields = nil |
| 642 | + r.values = nil |
| 643 | + return true |
| 644 | +} |
| 645 | + |
636 | 646 | // Connect to a database and verify with a ping.
|
637 | 647 | func Connect(driverName, dataSourceName string) (*DB, error) {
|
638 | 648 | db, err := Open(driverName, dataSourceName)
|
@@ -884,9 +894,9 @@ func structOnlyError(t reflect.Type) error {
|
884 | 894 | // then each row must only have one column which can scan into that type. This
|
885 | 895 | // allows you to do something like:
|
886 | 896 | //
|
887 |
| -// rows, _ := db.Query("select id from people;") |
888 |
| -// var ids []int |
889 |
| -// scanAll(rows, &ids, false) |
| 897 | +// rows, _ := db.Query("select id from people;") |
| 898 | +// var ids []int |
| 899 | +// scanAll(rows, &ids, false) |
890 | 900 | //
|
891 | 901 | // and ids will be a list of the id results. I realize that this is a desirable
|
892 | 902 | // interface to expose to users, but for now it will only be exposed via changes
|
|
0 commit comments