Skip to content

Commit

Permalink
fix(connection): fix validation for mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
danvergara committed Apr 22, 2021
1 parent 6cbcbc1 commit c69bcf3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ func formatPostgresURL(opts command.Options) (string, error) {
// formatMySQLURL returns valid uri for mysql connection.
func formatMySQLURL(opts command.Options) (string, error) {
if !hasValidMySQLPrefix(opts.URL) {
return "", ErrInvalidUMySQLRLFormat
return "", fmt.Errorf("%s, %w", opts.URL, ErrInvalidUMySQLRLFormat)
}

if strings.Contains(opts.URL, "3306") {
return opts.URL, nil
}

uri, err := url.Parse(opts.URL)
if err != nil {
return "", ErrInvalidUMySQLRLFormat
return "", fmt.Errorf("%v %w", err, ErrInvalidUMySQLRLFormat)
}

result := map[string]string{}
Expand Down

0 comments on commit c69bcf3

Please sign in to comment.