Skip to content

Commit

Permalink
add noOpScanType
Browse files Browse the repository at this point in the history
  • Loading branch information
br3w0r committed Mar 27, 2024
1 parent 5c09502 commit 9e370fb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dbscan/rowscanner.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dbscan

import (
"database/sql/driver"
"fmt"
"reflect"
)
Expand Down Expand Up @@ -123,13 +124,23 @@ func startScanner(rs *RowScanner, dstValue reflect.Value) error {
)
}

type noOpScanType struct{}

func (*noOpScanType) Scan(value interface{}) error {
return nil
}

func (noOpScanType) Value() (driver.Value, error) {
return nil, nil
}

func (rs *RowScanner) scanStruct(structValue reflect.Value) error {
scans := make([]interface{}, len(rs.columns))
for i, column := range rs.columns {
fieldIndex, ok := rs.columnToFieldIndex[column]
if !ok {
if rs.api.allowUnknownColumns {
var tmp interface{}
var tmp noOpScanType
scans[i] = &tmp
continue
}
Expand Down

0 comments on commit 9e370fb

Please sign in to comment.