Merge pull request #455 from Warashi/fix/use-defer

use defer prepareing for panic/recover
This commit is contained in:
Lunny Xiao 2016-09-26 13:56:53 +08:00 committed by GitHub
commit 6f15ac12bd
1 changed files with 1 additions and 1 deletions

View File

@ -848,6 +848,7 @@ func (engine *Engine) Having(conditions string) *Session {
func (engine *Engine) autoMapType(v reflect.Value) *core.Table {
t := v.Type()
engine.mutex.Lock()
defer engine.mutex.Unlock()
table, ok := engine.Tables[t]
if !ok {
table = engine.mapType(v)
@ -860,7 +861,6 @@ func (engine *Engine) autoMapType(v reflect.Value) *core.Table {
}
}
}
engine.mutex.Unlock()
return table
}