Review fixes
This commit is contained in:
parent
5b7c34e333
commit
b31464e491
2 changed files with 21 additions and 14 deletions
|
|
@ -3,6 +3,7 @@ package mysql
|
|||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/go-jet/jet/v2/generator/metadata"
|
||||
"github.com/go-jet/jet/v2/generator/template"
|
||||
|
|
@ -44,6 +45,14 @@ func Generate(destDir string, dbConn DBConnection, generatorTemplate ...template
|
|||
func GenerateDSN(dsn, destDir string, templates ...template.Template) (err error) {
|
||||
defer utils.ErrorCatch(&err)
|
||||
|
||||
// Special case for go mysql driver. It does not understand schema,
|
||||
// so we need to trim it before passing to generator
|
||||
// https://github.com/go-sql-driver/mysql#dsn-data-source-name
|
||||
idx := strings.Index(dsn, "://")
|
||||
if idx != -1 {
|
||||
dsn = dsn[idx+len("://"):]
|
||||
}
|
||||
|
||||
cfg, err := mysqldr.ParseDSN(dsn)
|
||||
throw.OnError(err)
|
||||
if cfg.DBName == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue