Verify that database name is specified when opening the connection

This commit is contained in:
Dan Sosedoff 2018-06-05 22:31:22 -05:00
parent 8ea8960696
commit 108754a8c3

View File

@ -119,6 +119,11 @@ func NewFromUrl(url string, sshInfo *shared.SSHInfo) (*Client, error) {
fmt.Println("Creating a new client for:", url)
}
uri, err := neturl.Parse(url)
if err == nil && uri.Path == "" {
return nil, fmt.Errorf("Database name is not provided")
}
db, err := sqlx.Open("postgres", url)
if err != nil {
return nil, err