Skip to content

Commit 7bbb54e

Browse files
committed
fix panic when error returned in bind/params.toValue
1 parent 18b8271 commit 7bbb54e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Fixed panic when error returned from parsing sql params
2+
13
## v3.98.0
24
* Supported pool of encoders, which implement ResetableWriter interface
35

internal/bind/params.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ func toValue(v interface{}) (_ value.Value, err error) {
315315
vv, err := toValue(v.Field(i).Interface())
316316
if err != nil {
317317
return nil, xerrors.WithStackTrace(
318-
fmt.Errorf("cannot parse %v as values of dict: %w",
319-
v.Index(i).Interface(), err,
318+
fmt.Errorf("cannot parse %v as values of struct: %w",
319+
v.Field(i).Interface(), err,
320320
),
321321
)
322322
}

internal/bind/params_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,16 @@ func TestToValue(t *testing.T) {
425425
)),
426426
err: nil,
427427
},
428+
{
429+
name: xtest.CurrentFileLine(),
430+
src: struct {
431+
A struct {
432+
Unsupported string
433+
} `sql:"A"`
434+
}{},
435+
dst: nil,
436+
err: errUnsupportedType,
437+
},
428438
{
429439
name: xtest.CurrentFileLine(),
430440
src: []uint64{123, 123, 123, 123, 123, 123},

0 commit comments

Comments
 (0)