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

database/sql over query service client #1580

Merged
merged 69 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d242af3
fix(sql): tmp queryservice default option
vladDotH Nov 10, 2024
ef54737
feat(internal/query/xsql): conn boilerplate
vladDotH Oct 30, 2024
152fd71
feat(internal/query/conn): driver initial implemetations
vladDotH Nov 10, 2024
6ee564b
feat(internal/query/conn): normalize & execContext fns
vladDotH Nov 10, 2024
76921eb
Merge remote-tracking branch 'ydb/master'
vladDotH Nov 10, 2024
0732759
feat(internal/query/xsql): tx options transform
vladDotH Nov 10, 2024
4ca5144
feat(internal/query/xsql): tx initials
vladDotH Nov 10, 2024
2678662
feat(intenral/query/xsql): rows impls
vladDotH Nov 13, 2024
e69f310
Merge branch 'ydb-platform:master' into master
vladDotH Nov 13, 2024
daa6a68
Merge branch 'ydb-platform:master' into master
vladDotH Nov 15, 2024
ff26c0b
feat(internal/query/conn): stmts
vladDotH Nov 15, 2024
29d44eb
feat(internal/query/conn/tx): ExecContext, PrepareContext impls
vladDotH Nov 15, 2024
2d20df5
feat(internal/query/conn): PrepareContext impl
vladDotH Nov 15, 2024
e750be4
fix(sql): xsql renamed
vladDotH Nov 17, 2024
f756a76
fix(internal/query/conn): currentTx interface
vladDotH Nov 17, 2024
c1d27ac
fix(internal/query): xsql rm
vladDotH Nov 17, 2024
ed723c4
feat(internal/query/conn): QueryContext impl
vladDotH Nov 17, 2024
10c3bd4
chore(internal/query/conn): linted
vladDotH Nov 17, 2024
28cd198
feat(internal/query/conn): remained impls
vladDotH Nov 17, 2024
fc89935
chore(internal/query/conn): linted
vladDotH Nov 17, 2024
691008c
Merge remote-tracking branch 'origin' into fork/vladDotH/master
asmyasnikov Nov 19, 2024
f479b3e
added YDB_DATABASE_SQL_OVER_QUERY_SERVICE env for run database/sql ov…
asmyasnikov Nov 19, 2024
1370a72
chore(internal/query/conn/rows): linted
vladDotH Nov 19, 2024
f976dd6
fix(internal/query/conn/tx): nil txc rm
vladDotH Nov 19, 2024
6ad28a9
fix(internal/query/conn/rows/Next): correct dst pointers array
vladDotH Nov 19, 2024
380baac
fix(internal/query/conn/rows): nextResultSets check & columns cache
vladDotH Nov 19, 2024
a0cc5a0
refactor(internal/table/context): public QueryModeFromContext
vladDotH Nov 19, 2024
b292289
feat(internal/query/conn): explain mode support
vladDotH Nov 19, 2024
8e5eaab
fix(internal/query/conn/rows): pure eof returning & NextResultSet fix
vladDotH Nov 19, 2024
9f78824
chore(internal/query/conn): linted
vladDotH Nov 19, 2024
a9f83c1
added YDB_DATABASE_SQL_OVER_QUERY_SERVICE env to experimental tests
asmyasnikov Nov 19, 2024
cc37fad
feat(internal/value): driver.Value force cast
vladDotH Nov 20, 2024
c7e7a04
fix(internal/query): resultSetIndex overflow check
vladDotH Nov 20, 2024
f4a2325
Apply suggestions from code review
asmyasnikov Nov 20, 2024
dbac1d7
fix(internal/value): cast error joining
vladDotH Nov 20, 2024
2f1071a
fix(internal/value/castTo): inner castTo calling revert
vladDotH Nov 20, 2024
410e804
fix(internal/value/castTo): Value.CastTo error wrapping
vladDotH Nov 20, 2024
dc27c84
refactor: QueryModes & querymodes funtions transfered to xcontext
vladDotH Nov 23, 2024
2ffc490
chore(internal/table/conn): linted
vladDotH Nov 23, 2024
b7e83f1
fix(internal/query/conn): badconn rm
vladDotH Nov 23, 2024
a948510
refactor(internal/value): force ptr value set in missing type casts
vladDotH Nov 24, 2024
60f2b54
fix(internal/query/conn): yql type & castResult
vladDotH Nov 24, 2024
75c7061
feat(interna/value/tupleValue.castTo): driver.Value switch
vladDotH Nov 24, 2024
5c47229
feat(internal/query/conn/rows): discarded columns support
vladDotH Nov 24, 2024
756153b
ci(database_sql_with_tx_control_test): temporary query service suppor…
vladDotH Nov 24, 2024
d974d4c
Merge branch 'ydb-platform:master' into master
vladDotH Nov 24, 2024
9f8f706
fix(internal/table/conn): query modes definitions
vladDotH Nov 24, 2024
85da81d
chore(internal/query/conn): linted
vladDotH Nov 24, 2024
21b6d88
Merge branch 'ydb-platform:master' into master
vladDotH Dec 9, 2024
3d61b65
fixed parameters
asmyasnikov Dec 9, 2024
9f7962d
extracted ExplainQueryMode to internal/connector, other query modes m…
asmyasnikov Dec 9, 2024
1ebcc3c
extraced internal/{table,query}/conn/stmt.go into internal/connector …
asmyasnikov Dec 10, 2024
e52398c
moved internal/{table,query}/conn to internal/connector/{table,query}
asmyasnikov Dec 10, 2024
46b1007
rename internal/connector to internal/xsql
asmyasnikov Dec 10, 2024
354fa07
Merge pull request #1552 from vladDotH/master
asmyasnikov Dec 10, 2024
92aeba7
renamed internal/xsql/iface to internal/xsql/conn + moved internal/xs…
asmyasnikov Dec 11, 2024
3f5638b
refactoring
asmyasnikov Dec 11, 2024
43abd71
refactoring + fixes
asmyasnikov Dec 11, 2024
7de1f3b
fixes
asmyasnikov Dec 11, 2024
6a8c400
fixed matrics for unit and integration tests
asmyasnikov Dec 11, 2024
5bd342d
fixed integration tests after removed ydb 23.3 from matrix
asmyasnikov Dec 11, 2024
33ae952
fixed integration tests with database/sql driver over query service
asmyasnikov Dec 11, 2024
09192ee
fixed tracing over database/sql
asmyasnikov Dec 11, 2024
6022f09
added record option info stack.FunctionID
asmyasnikov Dec 12, 2024
fd4142d
* Added implementation of `database/sql` driver over query service cl…
asmyasnikov Dec 12, 2024
9599936
fix linter issue
asmyasnikov Dec 12, 2024
0ed4ce6
fixed fake tx for scripting mode
asmyasnikov Dec 12, 2024
9d2c715
fixed matrix ydb versions for examples workflow
asmyasnikov Dec 12, 2024
8f69ba5
fixed go generated code
asmyasnikov Dec 12, 2024
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: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ydb-version: [ 23.3, 24.1 ]
ydb-version: [ 24.1, 24.2, 24.3 ]
application: [ native/table, native/query, database_sql, gorm, xorm ]
services:
ydb:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.21.x, 1.22.x, 1.23.x]
go-version: [1.22.x, 1.23.x]
os: [ubuntu, windows, macOS]
env:
OS: ${{ matrix.os }}-latest
Expand Down Expand Up @@ -52,8 +52,8 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.21.x, 1.22.x, 1.23.x]
ydb-version: [23.3, 24.1, 24.2]
go-version: [1.22.x, 1.23.x]
ydb-version: [24.1, 24.2, 24.3]
os: [ubuntu]
services:
ydb:
Expand Down Expand Up @@ -133,6 +133,7 @@ jobs:
YDB_CONNECTION_STRING_SECURE: grpcs://localhost:2135/local
YDB_SSL_ROOT_CERTIFICATES_FILE: /tmp/ydb_certs/ca.pem
YDB_SESSIONS_SHUTDOWN_URLS: http://localhost:8765/actors/kqp_proxy?force_shutdown=all
YDB_DATABASE_SQL_OVER_QUERY_SERVICE: 1
HIDE_APPLICATION_OUTPUT: 1
steps:
- name: Checkout code
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Added implementation of `database/sql` driver over query service client
* Added `ydb.WithQueryService(bool)` option to explicitly enable `database/sql` driver over query service client
* Added environment parameter `YDB_DATABASE_SQL_OVER_QUERY_SERVICE` to enable `database/sql` driver over query service client without code rewriting

## v3.94.0
* Refactored golang types mapping into ydb types using `ydb.ParamsFromMap` and `database/sql` query arguments
* Small breaking change: type mapping for `ydb.ParamsFromMap` and `database/sql` type `uuid.UUID` changed from ydb type `Text` to ydb type `UUID`
Expand Down
4 changes: 2 additions & 2 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/discovery"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector"
internalCoordination "github.com/ydb-platform/ydb-go-sdk/v3/internal/coordination"
coordinationConfig "github.com/ydb-platform/ydb-go-sdk/v3/internal/coordination/config"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
Expand All @@ -37,6 +36,7 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/topic/topicclientinternal"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync"
"github.com/ydb-platform/ydb-go-sdk/v3/log"
"github.com/ydb-platform/ydb-go-sdk/v3/operation"
Expand Down Expand Up @@ -93,7 +93,7 @@ type (
topic *xsync.Once[*topicclientinternal.Client]
topicOptions []topicoptions.TopicOption

databaseSQLOptions []connector.Option
databaseSQLOptions []xsql.Option

pool *conn.Pool

Expand Down
54 changes: 38 additions & 16 deletions dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/balancers"
"github.com/ydb-platform/ydb-go-sdk/v3/credentials"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/dsn"
tableSql "github.com/ydb-platform/ydb-go-sdk/v3/internal/table/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
)

const tablePathPrefixTransformer = "table_path_prefix"
Expand Down Expand Up @@ -44,6 +43,22 @@ func UnregisterDsnParser(registrationID int) {
dsnParsers[registrationID] = nil
}

var stringToType = map[string]QueryMode{
"data": DataQueryMode,
"scan": ScanQueryMode,
"scheme": SchemeQueryMode,
"scripting": ScriptingQueryMode,
"query": QueryExecuteQueryMode,
}

func queryModeFromString(s string) QueryMode {
if t, ok := stringToType[s]; ok {
return t
}

return unknownQueryMode
}

//nolint:funlen
func parseConnectionString(dataSourceName string) (opts []Option, _ error) {
info, err := dsn.Parse(dataSourceName)
Expand All @@ -60,45 +75,52 @@ func parseConnectionString(dataSourceName string) (opts []Option, _ error) {
opts = append(opts, WithBalancer(balancers.FromConfig(balancer)))
}
if queryMode := info.Params.Get("go_query_mode"); queryMode != "" {
mode := tableSql.QueryModeFromString(queryMode)
if mode == tableSql.UnknownQueryMode {
switch mode := queryModeFromString(queryMode); mode {
case QueryExecuteQueryMode:
opts = append(opts, withConnectorOptions(xsql.WithQueryService(true)))
case unknownQueryMode:
return nil, xerrors.WithStackTrace(fmt.Errorf("unknown query mode: %s", queryMode))
default:
opts = append(opts, withConnectorOptions(xsql.WithDefaultQueryMode(modeToMode(mode))))
}
opts = append(opts, withConnectorOptions(connector.WithDefaultQueryMode(mode)))
} else if queryMode := info.Params.Get("query_mode"); queryMode != "" {
mode := tableSql.QueryModeFromString(queryMode)
if mode == tableSql.UnknownQueryMode {
switch mode := queryModeFromString(queryMode); mode {
case QueryExecuteQueryMode:
opts = append(opts, withConnectorOptions(xsql.WithQueryService(true)))
case unknownQueryMode:
return nil, xerrors.WithStackTrace(fmt.Errorf("unknown query mode: %s", queryMode))
default:
opts = append(opts, withConnectorOptions(xsql.WithDefaultQueryMode(modeToMode(mode))))
}
opts = append(opts, withConnectorOptions(connector.WithDefaultQueryMode(mode)))
}
if fakeTx := info.Params.Get("go_fake_tx"); fakeTx != "" {
for _, queryMode := range strings.Split(fakeTx, ",") {
mode := tableSql.QueryModeFromString(queryMode)
if mode == tableSql.UnknownQueryMode {
switch mode := queryModeFromString(queryMode); mode {
case unknownQueryMode:
return nil, xerrors.WithStackTrace(fmt.Errorf("unknown query mode: %s", queryMode))
default:
opts = append(opts, withConnectorOptions(WithFakeTx(mode)))
}
opts = append(opts, withConnectorOptions(connector.WithFakeTx(mode)))
}
}
if info.Params.Has("go_query_bind") {
var binders []connector.Option
var binders []xsql.Option
queryTransformers := strings.Split(info.Params.Get("go_query_bind"), ",")
for _, transformer := range queryTransformers {
switch transformer {
case "declare":
binders = append(binders, connector.WithQueryBind(bind.AutoDeclare{}))
binders = append(binders, xsql.WithQueryBind(bind.AutoDeclare{}))
case "positional":
binders = append(binders, connector.WithQueryBind(bind.PositionalArgs{}))
binders = append(binders, xsql.WithQueryBind(bind.PositionalArgs{}))
case "numeric":
binders = append(binders, connector.WithQueryBind(bind.NumericArgs{}))
binders = append(binders, xsql.WithQueryBind(bind.NumericArgs{}))
default:
if strings.HasPrefix(transformer, tablePathPrefixTransformer) {
prefix, err := extractTablePathPrefixFromBinderName(transformer)
if err != nil {
return nil, xerrors.WithStackTrace(err)
}
binders = append(binders, connector.WithQueryBind(bind.TablePathPrefix(prefix)))
binders = append(binders, xsql.WithQueryBind(bind.TablePathPrefix(prefix)))
} else {
return nil, xerrors.WithStackTrace(
fmt.Errorf("unknown query rewriter: %s", transformer),
Expand Down
88 changes: 44 additions & 44 deletions dsn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (

"github.com/ydb-platform/ydb-go-sdk/v3/config"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector"
querySql "github.com/ydb-platform/ydb-go-sdk/v3/internal/query/conn"
tableSql "github.com/ydb-platform/ydb-go-sdk/v3/internal/table/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/legacy"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/propose"
)

func TestParse(t *testing.T) {
newConnector := func(opts ...connector.Option) *connector.Connector {
c := &connector.Connector{}
newConnector := func(opts ...xsql.Option) *xsql.Connector {
c := &xsql.Connector{}
for _, opt := range opts {
if opt != nil {
if err := opt.Apply(c); err != nil {
Expand All @@ -26,11 +26,11 @@ func TestParse(t *testing.T) {

return c
}
newTableConn := func(opts ...tableSql.Option) *tableSql.Conn {
return tableSql.New(context.Background(), nil, nil, opts...)
newLegacyConn := func(opts ...legacy.Option) *legacy.Conn {
return legacy.New(context.Background(), nil, nil, opts...)
}
newQueryConn := func(opts ...querySql.Option) *querySql.Conn {
return querySql.New(context.Background(), nil, nil, opts...)
newQueryConn := func(opts ...propose.Option) *propose.Conn {
return propose.New(context.Background(), nil, nil, opts...)
}
compareConfigs := func(t *testing.T, lhs, rhs *config.Config) {
require.Equal(t, lhs.Secure(), rhs.Secure())
Expand All @@ -40,7 +40,7 @@ func TestParse(t *testing.T) {
for _, tt := range []struct {
dsn string
opts []config.Option
connectorOpts []connector.Option
connectorOpts []xsql.Option
err error
}{
{
Expand Down Expand Up @@ -70,8 +70,8 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(tableSql.ScriptingQueryMode),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(legacy.ScriptingQueryMode),
},
err: nil,
},
Expand All @@ -82,9 +82,9 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(tableSql.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(legacy.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
},
err: nil,
},
Expand All @@ -95,10 +95,10 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(tableSql.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connector.WithQueryBind(bind.NumericArgs{}),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(legacy.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
xsql.WithQueryBind(bind.NumericArgs{}),
},
err: nil,
},
Expand All @@ -109,10 +109,10 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(tableSql.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connector.WithQueryBind(bind.PositionalArgs{}),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(legacy.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
xsql.WithQueryBind(bind.PositionalArgs{}),
},
err: nil,
},
Expand All @@ -123,10 +123,10 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(tableSql.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connector.WithQueryBind(bind.AutoDeclare{}),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(legacy.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
xsql.WithQueryBind(bind.AutoDeclare{}),
},
err: nil,
},
Expand All @@ -137,9 +137,9 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(tableSql.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(legacy.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
},
err: nil,
},
Expand All @@ -150,11 +150,11 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(tableSql.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connector.WithQueryBind(bind.PositionalArgs{}),
connector.WithQueryBind(bind.AutoDeclare{}),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(legacy.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
xsql.WithQueryBind(bind.PositionalArgs{}),
xsql.WithQueryBind(bind.AutoDeclare{}),
},
err: nil,
},
Expand All @@ -165,9 +165,9 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithFakeTx(tableSql.ScriptingQueryMode),
connector.WithFakeTx(tableSql.SchemeQueryMode),
connectorOpts: []xsql.Option{
WithFakeTx(ScriptingQueryMode),
WithFakeTx(SchemeQueryMode),
},
err: nil,
},
Expand All @@ -183,15 +183,15 @@ func TestParse(t *testing.T) {
exp := newConnector(tt.connectorOpts...)
act := newConnector(d.databaseSQLOptions...)
t.Run("tableOptions", func(t *testing.T) {
require.Equal(t, newTableConn(exp.TableOpts...), newTableConn(act.TableOpts...))
require.Equal(t, newLegacyConn(exp.LegacyOpts...), newLegacyConn(act.LegacyOpts...))
})
t.Run("queryOptions", func(t *testing.T) {
require.Equal(t, newQueryConn(exp.QueryOpts...), newQueryConn(act.QueryOpts...))
require.Equal(t, newQueryConn(exp.Options...), newQueryConn(act.Options...))
})
exp.TableOpts = nil
exp.QueryOpts = nil
act.TableOpts = nil
act.QueryOpts = nil
exp.LegacyOpts = nil
exp.Options = nil
act.LegacyOpts = nil
act.Options = nil
require.Equal(t, exp.Bindings(), act.Bindings())
require.Equal(t, exp, act)
compareConfigs(t, config.New(tt.opts...), d.config)
Expand Down
4 changes: 2 additions & 2 deletions examples/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ ALTER TABLE small_table3 SET (TTL = Interval("PT3H") ON d);
`
)

func executeQuery(ctx context.Context, c table.Client, prefix, query string) (err error) {
func executeQuery(ctx context.Context, c table.Client, prefix, sql string) (err error) {
err = c.Do(ctx,
func(ctx context.Context, s table.Session) error {
err = s.ExecuteSchemeQuery(ctx, fmt.Sprintf(query, prefix))
err = s.ExecuteSchemeQuery(ctx, fmt.Sprintf(sql, prefix))

return err
},
Expand Down
6 changes: 3 additions & 3 deletions internal/bind/auto_declare.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (m AutoDeclare) blockID() blockID {
return blockDeclare
}

func (m AutoDeclare) RewriteQuery(query string, args ...interface{}) (
func (m AutoDeclare) ToYdb(sql string, args ...interface{}) (
yql string, newArgs []interface{}, err error,
) {
params, err := Params(args...)
Expand All @@ -22,7 +22,7 @@ func (m AutoDeclare) RewriteQuery(query string, args ...interface{}) (
}

if len(params) == 0 {
return query, args, nil
return sql, args, nil
}

var (
Expand All @@ -46,7 +46,7 @@ func (m AutoDeclare) RewriteQuery(query string, args ...interface{}) (

buffer.WriteByte('\n')

buffer.WriteString(query)
buffer.WriteString(sql)

for _, param := range params {
newArgs = append(newArgs, param)
Expand Down
Loading
Loading