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

asasalint enable #978

Merged
merged 1 commit into from
Dec 30, 2023
Merged
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
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ linters-settings:
linters:
enable-all: true
disable:
- asasalint
- bodyclose
- containedctx
- contextcheck
Expand Down
2 changes: 1 addition & 1 deletion sugar/params_go1.18.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func GenerateDeclareSection[T *table.QueryParameters | []table.ParameterOption |
//
// Deprecated: use testutil/QueryBind helper
func ToYdbParam(param sql.NamedArg) (table.ParameterOption, error) {
params, err := bind.Params([]interface{}{param})
params, err := bind.Params(param)
if err != nil {
return nil, xerrors.WithStackTrace(err)
}
Expand Down
47 changes: 47 additions & 0 deletions sugar/params_go1.18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
"github.com/ydb-platform/ydb-go-sdk/v3/table"
"github.com/ydb-platform/ydb-go-sdk/v3/table/types"
"github.com/ydb-platform/ydb-go-sdk/v3/testutil"
Expand Down Expand Up @@ -270,3 +271,49 @@ func TestGenerateDeclareSection_NamedArg(t *testing.T) {
})
}
}

func TestToYdbParam(t *testing.T) {
for _, tt := range []struct {
name string
param sql.NamedArg
ydbParam table.ParameterOption
err error
}{
{
name: xtest.CurrentFileLine(),
param: sql.Named("a", "b"),
ydbParam: table.ValueParam("$a", types.TextValue("b")),
err: nil,
},
{
name: xtest.CurrentFileLine(),
param: sql.Named("a", 123),
ydbParam: table.ValueParam("$a", types.Int32Value(123)),
err: nil,
},
{
name: xtest.CurrentFileLine(),
param: sql.Named("a", types.OptionalValue(types.TupleValue(
types.BytesValue([]byte("test")),
types.TextValue("test"),
types.Uint64Value(123),
))),
ydbParam: table.ValueParam("$a", types.OptionalValue(types.TupleValue(
types.BytesValue([]byte("test")),
types.TextValue("test"),
types.Uint64Value(123),
))),
err: nil,
},
} {
t.Run(tt.name, func(t *testing.T) {
ydbParam, err := ToYdbParam(tt.param)
if tt.err != nil {
require.Error(t, err)
} else {
require.NoError(t, err)
require.Equal(t, tt.ydbParam, ydbParam)
}
})
}
}
Loading