-
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 INSERT statement normalization match backtick table name (#1366)
- Loading branch information
Showing
3 changed files
with
96 additions
and
2 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
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,54 @@ | ||
package issues | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/ClickHouse/clickhouse-go/v2/tests" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIssue1345(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
conn, err := tests.GetConnection("issues", nil, nil, nil) | ||
require.NoError(t, err) | ||
defer conn.Close() | ||
|
||
require.NoError(t, conn.Exec(ctx, "CREATE DATABASE IF NOT EXISTS `_test_1345#$.ДБ`")) | ||
defer conn.Exec(ctx, "DROP TABLE `_test_1345#$.ДБ`") | ||
|
||
require.NoError(t, conn.Exec(ctx, "CREATE TABLE IF NOT EXISTS `_test_1345#$.ДБ`.`2. Таблица №2` (i UInt64, s String) ENGINE = Memory()")) | ||
|
||
batch, err := conn.PrepareBatch(ctx, "INSERT INTO `_test_1345#$.ДБ`.`2. Таблица №2`") | ||
require.NoError(t, err) | ||
|
||
var ( | ||
i = uint64(32) | ||
s = "b" | ||
) | ||
|
||
err = batch.Append(i, s) | ||
require.NoError(t, err) | ||
|
||
err = batch.Send() | ||
require.NoError(t, err) | ||
|
||
rows, err := conn.Query(ctx, "SELECT * FROM `_test_1345#$.ДБ`.`2. Таблица №2`") | ||
require.NoError(t, err) | ||
|
||
require.True(t, rows.Next()) | ||
|
||
var ( | ||
actualInt uint64 | ||
actualStr string | ||
) | ||
err = rows.Scan(&actualInt, &actualStr) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, i, actualInt) | ||
require.Equal(t, s, actualStr) | ||
|
||
require.NoError(t, rows.Close()) | ||
require.NoError(t, rows.Err()) | ||
} |