@@ -857,6 +857,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)
@@ -869,7 +870,6 @@ func (engine *Engine) autoMapType(v reflect.Value) *core.Table {
}
- engine.mutex.Unlock()
return table
@@ -550,7 +550,8 @@ func genCols(table *core.Table, session *Session, bean interface{}, useCol bool,
- if (col.IsCreated || col.IsUpdated) && session.Statement.UseAutoTime {
+ if (col.IsCreated || col.IsUpdated) && session.Statement.UseAutoTime && !isZero(fieldValue.Interface()) {
+ // if time is non-empty, then set to auto time
val, t := session.Engine.NowTime2(col.SQLType.Name)
args = append(args, val)
@@ -17,7 +17,7 @@ import (
const (
// Version show the xorm's version
- Version string = "0.6.0.0923"
+ Version string = "0.6.0.0927"
)
func regDrvsNDialects() bool {