diff --git a/clickhouse_options.go b/clickhouse_options.go index 93a72a9a8a..c013160280 100644 --- a/clickhouse_options.go +++ b/clickhouse_options.go @@ -350,16 +350,17 @@ func (o *Options) fromDSN(in string) error { } o.HttpUrlPath = path default: - switch p := strings.ToLower(params.Get(v)); p { + raw := params.Get(v) + switch p := strings.ToLower(raw); p { case "true": o.Settings[v] = int(1) case "false": o.Settings[v] = int(0) default: - if n, err := strconv.Atoi(p); err == nil { + if n, err := strconv.Atoi(raw); err == nil { o.Settings[v] = n } else { - o.Settings[v] = p + o.Settings[v] = raw } } } diff --git a/clickhouse_options_test.go b/clickhouse_options_test.go index 82d2b2233f..29dd8dbcaa 100644 --- a/clickhouse_options_test.go +++ b/clickhouse_options_test.go @@ -498,6 +498,57 @@ func TestParseDSN(t *testing.T) { }, "", }, + { + "setting value preserves original case", + "clickhouse://127.0.0.1/test_database?log_comment=REQUEST_TYPE:proxy%3BUSER_ID:TEST", + &Options{ + Protocol: Native, + TLS: nil, + Addr: []string{"127.0.0.1"}, + Settings: Settings{ + "log_comment": "REQUEST_TYPE:proxy;USER_ID:TEST", + }, + Auth: Auth{ + Database: "test_database", + }, + scheme: "clickhouse", + }, + "", + }, + { + "setting boolean true is case insensitive", + "clickhouse://127.0.0.1/test_database?async_insert=True", + &Options{ + Protocol: Native, + TLS: nil, + Addr: []string{"127.0.0.1"}, + Settings: Settings{ + "async_insert": int(1), + }, + Auth: Auth{ + Database: "test_database", + }, + scheme: "clickhouse", + }, + "", + }, + { + "setting numeric value preserved", + "clickhouse://127.0.0.1/test_database?max_block_size=65505", + &Options{ + Protocol: Native, + TLS: nil, + Addr: []string{"127.0.0.1"}, + Settings: Settings{ + "max_block_size": int(65505), + }, + Auth: Auth{ + Database: "test_database", + }, + scheme: "clickhouse", + }, + "", + }, { "multiple hosts in HA mode", "clickhouse://127.0.0.1:9440,127.0.0.2:9440/test_database",