Skip to content

Commit

Permalink
Merge pull request #978 from ydb-platform/asasalint
Browse files Browse the repository at this point in the history
asasalint enable
  • Loading branch information
asmyasnikov authored Dec 30, 2023
2 parents d011ece + d0c4c2f commit 0480caf
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
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)
}
})
}
}

0 comments on commit 0480caf

Please sign in to comment.