Skip to content

Commit

Permalink
Merge pull request #1088 from j2gg0s/fix-support-scan-float32-to-float32
Browse files Browse the repository at this point in the history
fix: support scan float32 to float32
  • Loading branch information
j2gg0s authored Jan 3, 2025
2 parents 4505099 + a52e733 commit e60ae2a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions schema/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func init() {
reflect.Uint32: scanUint64,
reflect.Uint64: scanUint64,
reflect.Uintptr: scanUint64,
reflect.Float32: scanFloat64,
reflect.Float64: scanFloat64,
reflect.Float32: scanFloat,
reflect.Float64: scanFloat,
reflect.Complex64: nil,
reflect.Complex128: nil,
reflect.Array: nil,
Expand Down Expand Up @@ -214,11 +214,14 @@ func scanUint64(dest reflect.Value, src interface{}) error {
}
}

func scanFloat64(dest reflect.Value, src interface{}) error {
func scanFloat(dest reflect.Value, src interface{}) error {
switch src := src.(type) {
case nil:
dest.SetFloat(0)
return nil
case float32:
dest.SetFloat(float64(src))
return nil
case float64:
dest.SetFloat(src)
return nil
Expand Down

0 comments on commit e60ae2a

Please sign in to comment.