Skip to content

Commit

Permalink
Merge pull request ClickHouse#606 from ClickHouse/issue_592
Browse files Browse the repository at this point in the history
Error if no address
  • Loading branch information
gingerwizard authored Jun 7, 2022
2 parents 9e7744b + 707e818 commit a5c9ef7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
ErrAcquireConnTimeout = errors.New("clickhouse: acquire conn timeout. you can increase the number of max open conn or the dial timeout")
ErrUnsupportedServerRevision = errors.New("clickhouse: unsupported server revision")
ErrBindMixedParamsFormats = errors.New("clickhouse [bind]: mixed named, numeric or positional parameters")
ErrAcquireConnNoAddress = errors.New("clickhouse: no valid address supplied")
)

type OpError struct {
Expand Down Expand Up @@ -199,6 +200,9 @@ func (ch *clickhouse) dial(ctx context.Context) (conn *connect, err error) {
return conn, nil
}
}
if err == nil {
err = ErrAcquireConnNoAddress
}
return nil, err
}

Expand Down
17 changes: 17 additions & 0 deletions tests/issues/592_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package issues

import (
"context"
"github.com/ClickHouse/clickhouse-go/v2"
"github.com/stretchr/testify/assert"
"testing"
)

func Test592(t *testing.T) {
conn, err := clickhouse.Open(&clickhouse.Options{})
assert.NoError(t, err)

ctx := context.Background()
err = conn.Exec(ctx, "DROP TABLE test_connection")
assert.Error(t, err)
}

0 comments on commit a5c9ef7

Please sign in to comment.