-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix insertion of empty map into JSON column by using _dummy subcolumn (…
…#1116) * test: issue 1113 (insertion of empty map in JSON column) Signed-off-by: Leonardo Di Donato <[email protected]> * fix(lib/column): correctly handle empty maps in JSON columns Signed-off-by: Leonardo Di Donato <[email protected]> --------- Signed-off-by: Leonardo Di Donato <[email protected]>
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package issues | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/ClickHouse/clickhouse-go/v2" | ||
clickhouse_tests "github.com/ClickHouse/clickhouse-go/v2/tests" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test1113(t *testing.T) { | ||
var ( | ||
conn, err = clickhouse_tests.GetConnection("issues", clickhouse.Settings{ | ||
"max_execution_time": 60, | ||
"allow_experimental_object_type": true, | ||
}, nil, &clickhouse.Compression{ | ||
Method: clickhouse.CompressionLZ4, | ||
}) | ||
) | ||
ctx := context.Background() | ||
require.NoError(t, err) | ||
const ddl = "CREATE TABLE test_1113 (col_1 JSON, col_2 JSON) Engine MergeTree() ORDER BY tuple()" | ||
require.NoError(t, conn.Exec(ctx, ddl)) | ||
defer func() { | ||
conn.Exec(ctx, "DROP TABLE IF EXISTS test_1113") | ||
}() | ||
|
||
batch, err := conn.PrepareBatch(context.Background(), "INSERT INTO test_1113") | ||
require.NoError(t, err) | ||
|
||
v1 := map[string]struct { | ||
Str string | ||
}{"a": {Str: "value"}} | ||
v2 := map[string]any{} | ||
|
||
require.NoError(t, batch.Append(v1, v2)) | ||
require.NoError(t, batch.Send()) | ||
} |