Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix panic when error returned in bind/params.toValue #1612

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading