added BootStrap call in case where default db name is not used
This commit is contained in:
parent
0f78ddc53a
commit
cbfbf97af1
@ -45,8 +45,13 @@ func RegisterModelWithSuffix(suffix string, models ...interface{}) {
|
||||
// BootStrap Bootstrap models.
|
||||
// make All model parsed and can not add more models
|
||||
func BootStrap() {
|
||||
if dataBaseCache.getDefault() == nil {
|
||||
fmt.Println("must have one Register DataBase alias named `default`")
|
||||
BootStrapWithAlias("default")
|
||||
}
|
||||
|
||||
// BootStrap with alias
|
||||
func BootStrapWithAlias(alias string) {
|
||||
if _, ok := dataBaseCache.get(alias); !ok {
|
||||
fmt.Printf("must have one Register DataBase alias named %q\n", alias)
|
||||
debug.PrintStack()
|
||||
return
|
||||
}
|
||||
|
||||
@ -621,7 +621,6 @@ func (t *txOrm) RollbackUnlessCommit() error {
|
||||
|
||||
// NewOrm create new orm
|
||||
func NewOrm() Ormer {
|
||||
BootStrap() // execute only once
|
||||
return NewOrmUsingDB(`default`)
|
||||
}
|
||||
|
||||
@ -644,6 +643,8 @@ func NewOrmWithDB(driverName, aliasName string, db *sql.DB, params ...DBOption)
|
||||
}
|
||||
|
||||
func newDBWithAlias(al *alias) Ormer {
|
||||
BootStrapWithAlias(al.Name) // execute only once
|
||||
|
||||
o := new(orm)
|
||||
o.alias = al
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user