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.
|
// BootStrap Bootstrap models.
|
||||||
// make All model parsed and can not add more models
|
// make All model parsed and can not add more models
|
||||||
func BootStrap() {
|
func BootStrap() {
|
||||||
if dataBaseCache.getDefault() == nil {
|
BootStrapWithAlias("default")
|
||||||
fmt.Println("must have one Register DataBase alias named `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()
|
debug.PrintStack()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -621,7 +621,6 @@ func (t *txOrm) RollbackUnlessCommit() error {
|
|||||||
|
|
||||||
// NewOrm create new orm
|
// NewOrm create new orm
|
||||||
func NewOrm() Ormer {
|
func NewOrm() Ormer {
|
||||||
BootStrap() // execute only once
|
|
||||||
return NewOrmUsingDB(`default`)
|
return NewOrmUsingDB(`default`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,6 +643,8 @@ func NewOrmWithDB(driverName, aliasName string, db *sql.DB, params ...DBOption)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newDBWithAlias(al *alias) Ormer {
|
func newDBWithAlias(al *alias) Ormer {
|
||||||
|
BootStrapWithAlias(al.Name) // execute only once
|
||||||
|
|
||||||
o := new(orm)
|
o := new(orm)
|
||||||
o.alias = al
|
o.alias = al
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user