Skip to content

Commit

Permalink
Merge f67a293 into accd7fe
Browse files Browse the repository at this point in the history
  • Loading branch information
Gattermeier committed Feb 26, 2019
2 parents accd7fe + f67a293 commit 962ef59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions config/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ func (m *Config) DB() (*sql.DB, error) {

// String will return the MySQL connection string.
func (m *Config) String() string {
var port int
if m.Port == 0 {
m.Port = DefaultMySQLPort
port = DefaultMySQLPort
} else {
port = m.Port
}

var location string
if m.Location != "" {
m.Location = url.QueryEscape(m.Location)
location = url.QueryEscape(m.Location)
} else {
m.Location = url.QueryEscape(DefaultLocation)
location = url.QueryEscape(DefaultLocation)
}

args, _ := url.ParseQuery(m.AddtlDSNOptions)
Expand All @@ -80,9 +84,9 @@ func (m *Config) String() string {
m.User,
m.Pw,
m.Host,
m.Port,
port,
m.DBName,
m.Location,
location,
args.Encode(),
)
}
Expand Down
14 changes: 9 additions & 5 deletions config/postgresql/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,27 @@ func (p *Config) DB() (*sql.DB, error) {

// String will return the Postgresql connection string
func (p *Config) String() string {
var port int
if p.Port == 0 {
p.Port = DefaultPort
port = DefaultPort
} else {
port = p.Port
}

var SSLMode string
if p.SSLMode != "" {
p.SSLMode = url.QueryEscape(p.SSLMode)
SSLMode = url.QueryEscape(p.SSLMode)
} else {
p.SSLMode = url.QueryEscape(DefaultSSLMode)
SSLMode = url.QueryEscape(DefaultSSLMode)
}

return fmt.Sprintf("postgres://%s:%s@%s:%d/%s?sslmode=%s",
p.User,
p.Pw,
p.Host,
p.Port,
port,
p.DBName,
p.SSLMode,
SSLMode,
)
}

Expand Down

0 comments on commit 962ef59

Please sign in to comment.