Skip to content

Commit

Permalink
added YDB_DATABASE_SQL_OVER_QUERY_SERVICE env for run database/sql ov…
Browse files Browse the repository at this point in the history
…er query-service + fix rows.Scan
  • Loading branch information
asmyasnikov committed Nov 19, 2024
1 parent 691008c commit f479b3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions internal/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql/driver"
"io"
"os"
"time"

"github.com/google/uuid"
Expand Down Expand Up @@ -184,9 +185,15 @@ func (c *Connector) Close() error {

func Open(parent ydbDriver, balancer grpc.ClientConnInterface, opts ...Option) (_ *Connector, err error) {
c := &Connector{
parent: parent,
balancer: balancer,
queryProcessor: TABLE_SERVICE,
parent: parent,
balancer: balancer,
queryProcessor: func() queryProcessor {
if v, has := os.LookupEnv("YDB_DATABASE_SQL_OVER_QUERY_SERVICE"); has && v != "" {
return QUERY_SERVICE
}

return TABLE_SERVICE
}(),
clock: clockwork.NewRealClock(),
done: make(chan struct{}),
trace: &trace.DatabaseSQL{},
Expand Down
5 changes: 4 additions & 1 deletion internal/query/conn/rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"database/sql/driver"
"errors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xslices"

Check failure on line 8 in internal/query/conn/rows.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/ydb-platform/ydb-go-sdk/v3) (gci)
"io"
"sync"

Check failure on line 10 in internal/query/conn/rows.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 11 in internal/query/conn/rows.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `goimports`-ed with -local github.com/ydb-platform/ydb-go-sdk/v3 (goimports)
Expand Down Expand Up @@ -100,7 +101,9 @@ func (r *rows) Next(dst []driver.Value) error {
return badconn.Map(xerrors.WithStackTrace(err))
}

if err = nextRow.Scan(dst); err != nil {
if err = nextRow.Scan(xslices.Transform(dst, func(v driver.Value) any {
return &v
})...); err != nil {
return badconn.Map(xerrors.WithStackTrace(err))
}

Expand Down

0 comments on commit f479b3e

Please sign in to comment.