Skip to content

Commit

Permalink
fix panic when error returned in bind/params.toValue
Browse files Browse the repository at this point in the history
  • Loading branch information
4el0ve4ek committed Jan 21, 2025
1 parent 18b8271 commit 7bbb54e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Fixed panic when error returned from parsing sql params

## v3.98.0
* Supported pool of encoders, which implement ResetableWriter interface

Expand Down
4 changes: 2 additions & 2 deletions internal/bind/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ func toValue(v interface{}) (_ value.Value, err error) {
vv, err := toValue(v.Field(i).Interface())
if err != nil {
return nil, xerrors.WithStackTrace(
fmt.Errorf("cannot parse %v as values of dict: %w",
v.Index(i).Interface(), err,
fmt.Errorf("cannot parse %v as values of struct: %w",
v.Field(i).Interface(), err,
),
)
}
Expand Down
10 changes: 10 additions & 0 deletions internal/bind/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,16 @@ func TestToValue(t *testing.T) {
)),
err: nil,
},
{
name: xtest.CurrentFileLine(),
src: struct {
A struct {
Unsupported string
} `sql:"A"`
}{},
dst: nil,
err: errUnsupportedType,
},
{
name: xtest.CurrentFileLine(),
src: []uint64{123, 123, 123, 123, 123, 123},
Expand Down

0 comments on commit 7bbb54e

Please sign in to comment.