Skip to content

Commit 7e04a38

Browse files
committed
example: #406
1 parent 2b8b974 commit 7e04a38

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

tests/issues/406_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package issues
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/ClickHouse/clickhouse-go/v2"
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestIssue406(t *testing.T) {
12+
var (
13+
ctx = context.Background()
14+
conn, err = clickhouse.Open(&clickhouse.Options{
15+
Addr: []string{"127.0.0.1:9000"},
16+
Auth: clickhouse.Auth{
17+
Database: "default",
18+
Username: "default",
19+
Password: "",
20+
},
21+
Compression: &clickhouse.Compression{
22+
Method: clickhouse.CompressionLZ4,
23+
},
24+
//Debug: true,
25+
})
26+
)
27+
if assert.NoError(t, err) {
28+
if err := checkMinServerVersion(conn, 21, 9); err != nil {
29+
t.Skip(err.Error())
30+
return
31+
}
32+
const ddl = `
33+
CREATE TABLE issue_406 (
34+
Col1 Tuple(Array(Int32), Array(Int32))
35+
) Engine Memory
36+
`
37+
if err := conn.Exec(ctx, "DROP TABLE IF EXISTS issue_406"); assert.NoError(t, err) {
38+
if err := conn.Exec(ctx, ddl); assert.NoError(t, err) {
39+
if batch, err := conn.PrepareBatch(ctx, "INSERT INTO issue_406"); assert.NoError(t, err) {
40+
if err := batch.Append(
41+
[]interface{}{
42+
[]int32{1, 2, 3, 4, 5},
43+
[]int32{5, 1, 2, 3, 4},
44+
},
45+
); assert.NoError(t, err) {
46+
if err := batch.Send(); assert.NoError(t, err) {
47+
var col1 []interface{}
48+
if err := conn.QueryRow(ctx, "SELECT * FROM issue_406").Scan(&col1); assert.NoError(t, err) {
49+
assert.Equal(t, []interface{}{
50+
[]int32{1, 2, 3, 4, 5},
51+
[]int32{5, 1, 2, 3, 4},
52+
}, col1)
53+
}
54+
}
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)