bug fixed
This commit is contained in:
parent
cb75b2cd9c
commit
a7e7288163
|
@ -646,20 +646,18 @@ func (engine *Engine) Having(conditions string) *Session {
|
|||
|
||||
func (engine *Engine) autoMapType(v reflect.Value) *core.Table {
|
||||
t := v.Type()
|
||||
engine.mutex.RLock()
|
||||
engine.mutex.Lock()
|
||||
table, ok := engine.Tables[t]
|
||||
engine.mutex.RUnlock()
|
||||
if !ok {
|
||||
table = engine.mapType(v)
|
||||
engine.mutex.Lock()
|
||||
engine.Tables[t] = table
|
||||
if v.CanAddr() {
|
||||
engine.GobRegister(v.Addr().Interface())
|
||||
} else {
|
||||
engine.GobRegister(v.Interface())
|
||||
}
|
||||
engine.mutex.Unlock()
|
||||
}
|
||||
engine.mutex.Unlock()
|
||||
return table
|
||||
}
|
||||
|
||||
|
|
11
session.go
11
session.go
|
@ -2896,10 +2896,8 @@ func (session *Session) value2Interface(col *core.Column, fieldValue reflect.Val
|
|||
case reflect.String:
|
||||
return fieldValue.String(), nil
|
||||
case reflect.Struct:
|
||||
if fieldType == core.TimeType {
|
||||
switch fieldValue.Interface().(type) {
|
||||
case time.Time:
|
||||
t := fieldValue.Interface().(time.Time)
|
||||
if fieldType.ConvertibleTo(core.TimeType) {
|
||||
t := fieldValue.Convert(core.TimeType).Interface().(time.Time)
|
||||
if session.Engine.dialect.DBType() == core.MSSQL {
|
||||
if t.IsZero() {
|
||||
return nil, nil
|
||||
|
@ -2907,9 +2905,6 @@ func (session *Session) value2Interface(col *core.Column, fieldValue reflect.Val
|
|||
}
|
||||
tf := session.Engine.FormatTime(col.SQLType.Name, t)
|
||||
return tf, nil
|
||||
default:
|
||||
return fieldValue.Interface(), nil
|
||||
}
|
||||
}
|
||||
if fieldTable, ok := session.Engine.Tables[fieldValue.Type()]; ok {
|
||||
if len(fieldTable.PrimaryKeys) == 1 {
|
||||
|
@ -2919,7 +2914,7 @@ func (session *Session) value2Interface(col *core.Column, fieldValue reflect.Val
|
|||
return 0, fmt.Errorf("no primary key for col %v", col.Name)
|
||||
}
|
||||
} else {
|
||||
return 0, fmt.Errorf("Unsupported type %v\n", fieldValue.Type())
|
||||
return 0, fmt.Errorf("Unsupported type %v", fieldValue.Type())
|
||||
}
|
||||
case reflect.Complex64, reflect.Complex128:
|
||||
bytes, err := json.Marshal(fieldValue.Interface())
|
||||
|
|
|
@ -615,7 +615,7 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{},
|
|||
}
|
||||
} else {
|
||||
//TODO: how to handler?
|
||||
panic("not supported")
|
||||
panic(fmt.Sprintln("not supported", fieldValue.Interface(), "as", table.PrimaryKeys))
|
||||
}
|
||||
} else {
|
||||
val = fieldValue.Interface()
|
||||
|
|
Loading…
Reference in New Issue