bug fixed #84
This commit is contained in:
parent
11d36774e9
commit
26932e9b90
|
@ -286,7 +286,7 @@ func setColumnTime(bean interface{}, col *core.Column, t time.Time) {
|
||||||
if v.CanSet() {
|
if v.CanSet() {
|
||||||
switch v.Type().Kind() {
|
switch v.Type().Kind() {
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
v.Set(reflect.ValueOf(t))
|
v.Set(reflect.ValueOf(t).Convert(v.Type()))
|
||||||
case reflect.Int, reflect.Int64, reflect.Int32:
|
case reflect.Int, reflect.Int64, reflect.Int32:
|
||||||
v.SetInt(t.Unix())
|
v.SetInt(t.Unix())
|
||||||
case reflect.Uint, reflect.Uint64, reflect.Uint32:
|
case reflect.Uint, reflect.Uint64, reflect.Uint32:
|
||||||
|
|
10
session.go
10
session.go
|
@ -1671,11 +1671,11 @@ func (session *Session) _row2Bean(rows *core.Rows, fields []string, fieldsCount
|
||||||
fieldValue.SetUint(uint64(vv.Int()))
|
fieldValue.SetUint(uint64(vv.Int()))
|
||||||
}
|
}
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
if fieldType == core.TimeType {
|
if fieldType.ConvertibleTo(core.TimeType) {
|
||||||
if rawValueType == core.TimeType {
|
if rawValueType == core.TimeType {
|
||||||
hasAssigned = true
|
hasAssigned = true
|
||||||
|
|
||||||
t := vv.Interface().(time.Time)
|
t := vv.Convert(core.TimeType).Interface().(time.Time)
|
||||||
z, _ := t.Zone()
|
z, _ := t.Zone()
|
||||||
if len(z) == 0 || t.Year() == 0 { // !nashtsai! HACK tmp work around for lib/pq doesn't properly time with location
|
if len(z) == 0 || t.Year() == 0 { // !nashtsai! HACK tmp work around for lib/pq doesn't properly time with location
|
||||||
session.Engine.LogDebug("empty zone key[%v] : %v | zone: %v | location: %+v\n", key, t, z, *t.Location())
|
session.Engine.LogDebug("empty zone key[%v] : %v | zone: %v | location: %+v\n", key, t, z, *t.Location())
|
||||||
|
@ -1684,7 +1684,7 @@ func (session *Session) _row2Bean(rows *core.Rows, fields []string, fieldsCount
|
||||||
vv = reflect.ValueOf(tt)
|
vv = reflect.ValueOf(tt)
|
||||||
}
|
}
|
||||||
// !nashtsai! convert to engine location
|
// !nashtsai! convert to engine location
|
||||||
t = vv.Interface().(time.Time).In(session.Engine.TZLocation)
|
t = vv.Convert(core.TimeType).Interface().(time.Time).In(session.Engine.TZLocation)
|
||||||
vv = reflect.ValueOf(t)
|
vv = reflect.ValueOf(t)
|
||||||
fieldValue.Set(vv)
|
fieldValue.Set(vv)
|
||||||
|
|
||||||
|
@ -2360,13 +2360,13 @@ func (session *Session) bytes2Value(col *core.Column, fieldValue *reflect.Value,
|
||||||
fieldValue.SetUint(x)
|
fieldValue.SetUint(x)
|
||||||
//Currently only support Time type
|
//Currently only support Time type
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
if fieldType == core.TimeType {
|
if fieldType.ConvertibleTo(core.TimeType) {
|
||||||
x, err := session.byte2Time(col, data)
|
x, err := session.byte2Time(col, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
v = x
|
v = x
|
||||||
fieldValue.Set(reflect.ValueOf(v))
|
fieldValue.Set(reflect.ValueOf(v).Convert(fieldType))
|
||||||
} else if session.Statement.UseCascade {
|
} else if session.Statement.UseCascade {
|
||||||
table := session.Engine.autoMapType(*fieldValue)
|
table := session.Engine.autoMapType(*fieldValue)
|
||||||
if table != nil {
|
if table != nil {
|
||||||
|
|
|
@ -583,8 +583,8 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{},
|
||||||
t := int64(fieldValue.Uint())
|
t := int64(fieldValue.Uint())
|
||||||
val = reflect.ValueOf(&t).Interface()
|
val = reflect.ValueOf(&t).Interface()
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
if fieldType == reflect.TypeOf(time.Now()) {
|
if fieldType.ConvertibleTo(core.TimeType) {
|
||||||
t := fieldValue.Interface().(time.Time)
|
t := fieldValue.Convert(core.TimeType).Interface().(time.Time)
|
||||||
if !requiredField && (t.IsZero() || !fieldValue.IsValid()) {
|
if !requiredField && (t.IsZero() || !fieldValue.IsValid()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue