Merge pull request #69 from bcho/fix/mysql-url-password-encode

prevent net/url encoding the user password
This commit is contained in:
Dale Hui 2018-06-29 14:17:45 -07:00 committed by GitHub
commit 78d696c1e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -90,6 +90,7 @@ func WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {
}
func (m *Mysql) Open(url string) (database.Driver, error) {
url = strings.TrimPrefix(url, "mysql://")
purl, err := nurl.Parse(url)
if err != nil {
return nil, err
@ -99,8 +100,7 @@ func (m *Mysql) Open(url string) (database.Driver, error) {
q.Set("multiStatements", "true")
purl.RawQuery = q.Encode()
db, err := sql.Open("mysql", strings.Replace(
migrate.FilterCustomQuery(purl).String(), "mysql://", "", 1))
db, err := sql.Open("mysql", migrate.FilterCustomQuery(purl).String())
if err != nil {
return nil, err
}