Skip to content

Commit

Permalink
example: #406
Browse files Browse the repository at this point in the history
  • Loading branch information
kshvakov committed Jan 17, 2022
1 parent 2b8b974 commit 7e04a38
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/issues/406_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package issues

import (
"context"
"testing"

"github.com/ClickHouse/clickhouse-go/v2"
"github.com/stretchr/testify/assert"
)

func TestIssue406(t *testing.T) {
var (
ctx = context.Background()
conn, err = clickhouse.Open(&clickhouse.Options{
Addr: []string{"127.0.0.1:9000"},
Auth: clickhouse.Auth{
Database: "default",
Username: "default",
Password: "",
},
Compression: &clickhouse.Compression{
Method: clickhouse.CompressionLZ4,
},
//Debug: true,
})
)
if assert.NoError(t, err) {
if err := checkMinServerVersion(conn, 21, 9); err != nil {
t.Skip(err.Error())
return
}
const ddl = `
CREATE TABLE issue_406 (
Col1 Tuple(Array(Int32), Array(Int32))
) Engine Memory
`
if err := conn.Exec(ctx, "DROP TABLE IF EXISTS issue_406"); assert.NoError(t, err) {
if err := conn.Exec(ctx, ddl); assert.NoError(t, err) {
if batch, err := conn.PrepareBatch(ctx, "INSERT INTO issue_406"); assert.NoError(t, err) {
if err := batch.Append(
[]interface{}{
[]int32{1, 2, 3, 4, 5},
[]int32{5, 1, 2, 3, 4},
},
); assert.NoError(t, err) {
if err := batch.Send(); assert.NoError(t, err) {
var col1 []interface{}
if err := conn.QueryRow(ctx, "SELECT * FROM issue_406").Scan(&col1); assert.NoError(t, err) {
assert.Equal(t, []interface{}{
[]int32{1, 2, 3, 4, 5},
[]int32{5, 1, 2, 3, 4},
}, col1)
}
}
}
}
}
}
}
}

0 comments on commit 7e04a38

Please sign in to comment.