Skip to content

Commit

Permalink
PMM-12551 Another fix for new connection string.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Mar 21, 2024
1 parent 2d55e0b commit c7da376
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions qan-api2/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ func createDB(dsn string) error {
if err != nil {
return err
}
q := clickhouseURL.Query()
databaseName := q.Get("database")
q.Set("database", "default")

clickhouseURL.RawQuery = q.Encode()
databaseName := strings.Replace(clickhouseURL.Path, "/", "", 1)
clickhouseURL.Path = "/default"

defaultDB, err := sqlx.Connect("clickhouse", clickhouseURL.String())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion qan-api2/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ func TestCreateDbIfNotExists(t *testing.T) {

db := createDB(dsn)

require.Equal(t, db, nil, "Check connection after we create database")
require.Equal(t, nil, db, "Check connection after we create database")
})
}

0 comments on commit c7da376

Please sign in to comment.