Browse Source

bug fixed

xormplus 9 years ago
parent
commit
427a8e34c4
3 changed files with 4 additions and 3 deletions
  1. 1 1
      engine.go
  2. 2 1
      helpers.go
  3. 1 1
      xorm.go

+ 1 - 1
engine.go

@@ -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
 }
 

+ 2 - 1
helpers.go

@@ -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)
 

+ 1 - 1
xorm.go

@@ -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 {