Skip to content

Commit

Permalink
fix: support scan float32 to float32/float64
Browse files Browse the repository at this point in the history
Close #1087
  • Loading branch information
j2gg0s committed Dec 18, 2024
1 parent 014b142 commit a52e733
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 a52e733

Please sign in to comment.