Skip to content

Commit

Permalink
try to use sql.Scanner prior to handleConvert
Browse files Browse the repository at this point in the history
  • Loading branch information
deen committed Mar 10, 2021
1 parent 1d0b691 commit 0f24429
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 147 deletions.
9 changes: 5 additions & 4 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,17 @@ func convert(mapValue interface{}, valuei reflect.Value, wrapErr convertErrWrapp
valuei.Set(reflect.ValueOf(mapValue))
return nil
}

if scanner, ok := valuei.Addr().Interface().(sql.Scanner); ok {
return scanner.Scan(mapValue)
}

//time.Time to string
switch assertT := mapValue.(type) {
case time.Time:
return handleConvertTime(assertT, mvt, vit, &valuei, wrapErr)
}

if scanner, ok := valuei.Addr().Interface().(sql.Scanner); ok {
return scanner.Scan(mapValue)
}

//according to go-mysql-driver/mysql, driver.Value type can only be:
//int64 or []byte(> maxInt64)
//float32/float64
Expand Down
Loading

0 comments on commit 0f24429

Please sign in to comment.