Skip to content

Commit

Permalink
move settings outside initial connect for std sql tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerTorres committed Jan 10, 2025
1 parent 0168089 commit ecd8d93
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
9 changes: 6 additions & 3 deletions examples/std/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import (
func DynamicExample() error {
ctx := context.Background()

conn, err := GetStdOpenDBConnection(clickhouse.Native, clickhouse.Settings{
"allow_experimental_dynamic_type": true,
}, nil, nil)
conn, err := GetStdOpenDBConnection(clickhouse.Native, nil, nil, nil)
if err != nil {
return err
}
Expand All @@ -38,6 +36,11 @@ func DynamicExample() error {
return nil
}

_, err = conn.ExecContext(ctx, "SET allow_experimental_dynamic_type = 1")
if err != nil {
return err
}

defer func() {
conn.Exec("DROP TABLE go_dynamic_example")
}()
Expand Down
15 changes: 11 additions & 4 deletions examples/std/variant.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ import (
func VariantExample() error {
ctx := context.Background()

conn, err := GetStdOpenDBConnection(clickhouse.Native, clickhouse.Settings{
"allow_experimental_variant_type": true,
"allow_suspicious_variant_types": true,
}, nil, nil)
conn, err := GetStdOpenDBConnection(clickhouse.Native, nil, nil, nil)
if err != nil {
return err
}
Expand All @@ -40,6 +37,16 @@ func VariantExample() error {
return nil
}

_, err = conn.ExecContext(ctx, "SET allow_experimental_variant_type = 1")
if err != nil {
return err
}

_, err = conn.ExecContext(ctx, "SET allow_suspicious_variant_types = 1")
if err != nil {
return err
}

defer func() {
conn.Exec("DROP TABLE go_variant_example")
}()
Expand Down
11 changes: 7 additions & 4 deletions tests/std/dynamic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ import (
var dynamicTestDate, _ = time.Parse(time.RFC3339, "2024-12-13T02:09:30.123Z")

func setupDynamicTest(t *testing.T) *sql.DB {
conn, err := GetStdOpenDBConnection(clickhouse.Native, clickhouse.Settings{
"max_execution_time": 60,
"allow_experimental_dynamic_type": true,
}, nil, &clickhouse.Compression{
conn, err := GetStdOpenDBConnection(clickhouse.Native, nil, nil, &clickhouse.Compression{
Method: clickhouse.CompressionLZ4,
})
require.NoError(t, err)
Expand All @@ -45,6 +42,12 @@ func setupDynamicTest(t *testing.T) *sql.DB {
return nil
}

_, err = conn.ExecContext(context.Background(), "SET allow_experimental_dynamic_type = 1")
if err != nil {
t.Fatal(err)
return nil
}

return conn
}

Expand Down
18 changes: 13 additions & 5 deletions tests/std/variant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ import (
var variantTestDate, _ = time.Parse(time.RFC3339, "2024-12-13T02:09:30.123Z")

func setupVariantTest(t *testing.T) *sql.DB {
conn, err := GetStdOpenDBConnection(clickhouse.Native, clickhouse.Settings{
"max_execution_time": 60,
"allow_experimental_variant_type": true,
"allow_suspicious_variant_types": true,
}, nil, &clickhouse.Compression{
conn, err := GetStdOpenDBConnection(clickhouse.Native, nil, nil, &clickhouse.Compression{
Method: clickhouse.CompressionLZ4,
})
require.NoError(t, err)
Expand All @@ -46,6 +42,18 @@ func setupVariantTest(t *testing.T) *sql.DB {
return nil
}

_, err = conn.ExecContext(context.Background(), "SET allow_experimental_variant_type = 1")
if err != nil {
t.Fatal(err)
return nil
}

_, err = conn.ExecContext(context.Background(), "SET allow_suspicious_variant_types = 1")
if err != nil {
t.Fatal(err)
return nil
}

return conn
}

Expand Down

0 comments on commit ecd8d93

Please sign in to comment.