-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version 2.6.1 numeric bind conflict with column named like "$360_name" #905
Comments
That's an interesting case. The binding mechanism has depreciated since we introduced CH native query parameters support. It gets disabled if you use native query parameters, but in your case, you are not interested in doing that. |
|
@WillMeng, there is a mechanism called query parameters natively supported by CH: https://clickhouse.com/docs/en/interfaces/cli#cli-queries-with-parameters This doc is explaining how to use it with a CH CLI client. For a I found this issue unreproducable. Can you post a code snippet? Here is my attempt to reproduce it with a test: package issues
import (
"context"
"fmt"
"github.com/ClickHouse/clickhouse-go/v2"
clickhouse_tests "github.com/ClickHouse/clickhouse-go/v2/tests"
"github.com/stretchr/testify/require"
"testing"
)
func Test905(t *testing.T) {
var (
conn, err = clickhouse_tests.GetConnection("issues", clickhouse.Settings{
"max_execution_time": 60,
"flatten_nested": 0,
}, nil, &clickhouse.Compression{
Method: clickhouse.CompressionLZ4,
})
)
ctx := context.Background()
require.NoError(t, err)
env, err := clickhouse_tests.GetTestEnvironment(testSet)
require.NoError(t, err)
ddl := fmt.Sprintf("CREATE TABLE `%s`.`test_905` (`$360_name` String, `$360_call_num` Int32) Engine MergeTree() ORDER BY tuple()", env.Database)
defer func() {
conn.Exec(ctx, fmt.Sprintf("DROP TABLE IF EXISTS `%s`.`test_905`", env.Database))
}()
require.NoError(t, conn.Exec(ctx, ddl))
err = conn.Exec(ctx, fmt.Sprintf("INSERT INTO `%s`.`test_905` (`$360_name`, `$360_call_num`) VALUES ('foo', 5)", env.Database))
require.NoError(t, err)
} |
err = conn.Exec(ctx, fmt.Sprintf("INSERT INTO `%s`.`test_905` (`$360_name`, `$360_call_num`) VALUES ($1, $2)", env.Database), 'foo', 5) |
@jkaflik Thank you |
@WillMeng thanks. I see what's the deal here. This is only reproducible if you provide an args and have a positional bind. What I can suggest you to do, is to adapt your code to use native query parameters: execCtx := clickhouse.Context(ctx, clickhouse.WithParameters(clickhouse.Parameters{
"name": "foo",
"callNum": "5",
}))
err = conn.Exec(execCtx, fmt.Sprintf("INSERT INTO `%s`.`test_905` (`$360_name`, `$360_call_num`) VALUES ({name:String}, {callNum:Int32})", env.Database)) or by using NamedArg: err = conn.Exec(
ctx,
fmt.Sprintf("INSERT INTO `%s`.`test_905` (`$360_name`, `$360_call_num`) VALUES ({name:String}, {callNum:Int32})", env.Database),
clickhouse.Named("name", "foo"),
clickhouse.Named("callNum", "5"),
) Also, you can consider using Like I said, binding mechanism is no longer supported, so no further improvements are planned. |
Thanks very much, I got it |
@WillMeng, you are welcome. Feel free to reach out to me in case of any questions. |
Issue description
We have table_schema like this:
Example code
Error log
Configuration
*OS: centos 7.9
Interface: clickhouse interface (formally native interface)
*Driver version: 2.6.1
Go version: 1.20
*ClickHouse Server version: 22.3
The text was updated successfully, but these errors were encountered: