Closed night1008 closed 5 months ago
Hi @night1008
Since the error is not thrown in ClickHouse at the time of query retrieval but later with the data packet, the client has to process data received from the server explicitly using rows.Next()
.
See code snippet:
package issues
import (
"context"
"testing"
clickhouse_tests "github.com/ClickHouse/clickhouse-go/v2/tests"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test1268(t *testing.T) {
conn, err := clickhouse_tests.GetDatabaseSQLConnection("issues", nil, nil, nil)
require.NoError(t, err)
rows, err := conn.QueryContext(context.Background(), "select sleep(300)")
require.NoError(t, err)
defer rows.Close()
for rows.Next() {
if rows.Err() != nil {
break
}
}
assert.ErrorContains(t, rows.Err(), "code: 160, message: The maximum sleep time is 3000000 microseconds.")
}
Perhaps you have any reason to not call rows.Next()
?
I see. Thanks!
Expected behaviour
Environment
clickhouse-go
version: v2.13.0database/sql
compatible driver:database/sql