Skip to content

Commit b0d6afa

Browse files
Merge pull request #1541 from kokizzu/fix-clickhouse-proxy-issue
Fix clickhouse proxy issue, add support for database as query string DSN
2 parents 8219540 + b3b56a5 commit b0d6afa

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

clickhouse_options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ func (o *Options) fromDSN(in string) error {
308308
o.Auth.Username = params.Get(v)
309309
case "password":
310310
o.Auth.Password = params.Get(v)
311+
case "database":
312+
o.Auth.Database = params.Get(v)
311313
case "client_info_product":
312314
chunks := strings.Split(params.Get(v), ",")
313315

clickhouse_options_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,21 @@ func TestParseDSN(t *testing.T) {
482482
},
483483
"",
484484
},
485+
{
486+
"clickhouse proxy with database as query string",
487+
"tcp://127.0.0.1/?database=bla",
488+
&Options{
489+
Protocol: Native,
490+
TLS: nil,
491+
Addr: []string{"127.0.0.1"},
492+
Settings: Settings{},
493+
Auth: Auth{
494+
Database: `bla`,
495+
},
496+
scheme: "tcp",
497+
},
498+
"",
499+
},
485500
}
486501

487502
for _, testCase := range testCases {

0 commit comments

Comments
 (0)