From 707e818e810c8fb2eaaa8b8b2991fd65d509ed29 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Tue, 7 Jun 2022 15:46:02 +0100 Subject: [PATCH] Error if no address --- clickhouse.go | 4 ++++ tests/issues/592_test.go | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/issues/592_test.go diff --git a/clickhouse.go b/clickhouse.go index 5b4a36d3fb..351cc6cfa6 100644 --- a/clickhouse.go +++ b/clickhouse.go @@ -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 { @@ -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 } diff --git a/tests/issues/592_test.go b/tests/issues/592_test.go new file mode 100644 index 0000000000..995c9a51e9 --- /dev/null +++ b/tests/issues/592_test.go @@ -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) +}