Skip to content

Commit a37bb62

Browse files
committed
optimize
1 parent be8e2d9 commit a37bb62

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

database/db/row.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func ToScannerHookFunc() mapstructure.DecodeHookFunc {
134134

135135
// Call the Scan method with the data
136136
if err := scanner.Scan(scanData); err != nil {
137-
return data, err
137+
return nil, err
138138
}
139139

140140
return result.Elem().Interface(), nil
@@ -159,7 +159,7 @@ func ToSliceHookFunc() mapstructure.DecodeHookFunc {
159159

160160
result := reflect.New(t).Interface()
161161
if err := json.Unmarshal([]byte(str), result); err != nil {
162-
return data, nil
162+
return nil, err
163163
}
164164

165165
return reflect.ValueOf(result).Elem().Interface(), nil
@@ -184,7 +184,7 @@ func ToMapHookFunc() mapstructure.DecodeHookFunc {
184184

185185
result := reflect.MakeMap(t).Interface()
186186
if err := json.Unmarshal([]byte(str), &result); err != nil {
187-
return data, nil
187+
return nil, err
188188
}
189189

190190
return result, nil

tests/query_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package tests
22

33
import (
44
"context"
5-
"database/sql/driver"
65
"encoding/json"
76
"fmt"
87
"strconv"
@@ -763,11 +762,6 @@ type ResultData struct {
763762
}
764763
}
765764

766-
func (r *ResultData) Value() (driver.Value, error) {
767-
bytes, err := json.Marshal(r)
768-
return string(bytes), err
769-
}
770-
771765
func (r *ResultData) Scan(value any) (err error) {
772766
if data, ok := value.([]byte); ok && len(data) > 0 {
773767
err = json.Unmarshal(data, &r)

0 commit comments

Comments
 (0)