Skip to content

Commit 8a64ee6

Browse files
committed
Implement RowsColumnScanner.
1 parent 8f9a8e2 commit 8a64ee6

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

driver/driver.go

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,6 @@ func (r resultRowsAffected) RowsAffected() (int64, error) {
604604
return int64(r), nil
605605
}
606606

607-
type rows struct {
608-
ctx context.Context
609-
*stmt
610-
names []string
611-
types []string
612-
nulls []bool
613-
scans []scantype
614-
}
615-
616607
type scantype byte
617608

618609
const (
@@ -648,10 +639,20 @@ func scanFromDecl(decl string) scantype {
648639
return _ANY
649640
}
650641

642+
type rows struct {
643+
ctx context.Context
644+
*stmt
645+
names []string
646+
types []string
647+
nulls []bool
648+
scans []scantype
649+
}
650+
651651
var (
652652
// Ensure these interfaces are implemented:
653653
_ driver.RowsColumnTypeDatabaseTypeName = &rows{}
654654
_ driver.RowsColumnTypeNullable = &rows{}
655+
// _ driver.RowsColumnScanner = &rows{}
655656
)
656657

657658
func (r *rows) Close() error {
@@ -830,3 +831,23 @@ func (r *rows) Next(dest []driver.Value) error {
830831
}
831832
return nil
832833
}
834+
835+
func (r *rows) ScanColumn(dest any, index int) error {
836+
// notest // Go 1.26
837+
var ptr *time.Time
838+
switch d := dest.(type) {
839+
case *time.Time:
840+
ptr = d
841+
case *sql.NullTime:
842+
ptr = &d.Time
843+
case *sql.Null[time.Time]:
844+
ptr = &d.V
845+
default:
846+
return driver.ErrSkip
847+
}
848+
if t := r.Stmt.ColumnTime(index, r.tmRead); !t.IsZero() {
849+
*ptr = t
850+
return nil
851+
}
852+
return driver.ErrSkip
853+
}

0 commit comments

Comments
 (0)