| 590 | } |
| 591 | |
| 592 | func (db *DB) ScanRows(rows *sql.Rows, dest interface{}) error { |
| 593 | tx := db.getInstance() |
| 594 | if err := tx.Statement.Parse(dest); !errors.Is(err, schema.ErrUnsupportedDataType) { |
| 595 | tx.AddError(err) |
| 596 | } |
| 597 | tx.Statement.Dest = dest |
| 598 | tx.Statement.ReflectValue = reflect.ValueOf(dest) |
| 599 | for tx.Statement.ReflectValue.Kind() == reflect.Ptr { |
| 600 | elem := tx.Statement.ReflectValue.Elem() |
| 601 | if !elem.IsValid() { |
| 602 | elem = reflect.New(tx.Statement.ReflectValue.Type().Elem()) |
| 603 | tx.Statement.ReflectValue.Set(elem) |
| 604 | } |
| 605 | tx.Statement.ReflectValue = elem |
| 606 | } |
| 607 | Scan(rows, tx, ScanInitialized) |
| 608 | return tx.Error |
| 609 | } |
| 610 | |
| 611 | // Connection uses a db connection to execute an arbitrary number of commands in fc. When finished, the connection is |
| 612 | // returned to the connection pool. |