Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions clickhouse_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
51 changes: 51 additions & 0 deletions clickhouse_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down