Skip to content

Commit 9c0cfd0

Browse files
committed
accept empty dsn
1 parent 19ffbe5 commit 9c0cfd0

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

connection.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ func open(ctx context.Context, opts ...Option) (_ Connection, err error) {
253253
}
254254
}
255255
for _, opt := range opts {
256+
if opt == nil {
257+
continue
258+
}
256259
err = opt(ctx, c)
257260
if err != nil {
258261
return nil, xerrors.WithStackTrace(err)

options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ func WithRequestsType(requestsType string) Option {
6262
// Warning: WithConnectionString will be removed at next major release
6363
// (connection string will be required string param of ydb.Open)
6464
func WithConnectionString(connectionString string) Option {
65+
if connectionString == "" {
66+
return nil
67+
}
6568
return func(ctx context.Context, c *connection) error {
6669
options, err := dsn.Parse(connectionString)
6770
if err != nil {

test/connection_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ func TestConnection(t *testing.T) {
6464
defer cancel()
6565
db, err := ydb.Open(
6666
ctx,
67-
os.Getenv("YDB_CONNECTION_STRING"),
67+
"", // corner case for check replacement of endpoint+database+secure
68+
ydb.WithConnectionString(os.Getenv("YDB_CONNECTION_STRING")),
6869
ydb.WithAnonymousCredentials(),
6970
ydb.With(
7071
config.WithOperationTimeout(time.Second*2),

0 commit comments

Comments
 (0)