fix bug for mis-converting uint64 to int64 (#1647)

fix bug for mis-converting uint64 to int64

Co-authored-by: rosbit <me@rosbit.cn>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1647
This commit is contained in:
rosbit 2020-04-05 04:49:44 +00:00 committed by Lunny Xiao
parent 410c2de923
commit 7e981f5f5e
3 changed files with 3 additions and 5 deletions

View File

@ -797,8 +797,7 @@ func (statement *Statement) buildConds2(table *schemas.Table, bean interface{},
if !requiredField && fieldValue.Uint() == 0 {
continue
}
t := int64(fieldValue.Uint())
val = reflect.ValueOf(&t).Interface()
val = fieldValue.Interface()
case reflect.Struct:
if fieldType.ConvertibleTo(schemas.TimeType) {
t := fieldValue.Convert(schemas.TimeType).Interface().(time.Time)

View File

@ -190,8 +190,7 @@ func (statement *Statement) BuildUpdates(tableValue reflect.Value,
if !requiredField && fieldValue.Uint() == 0 {
continue
}
t := int64(fieldValue.Uint())
val = reflect.ValueOf(&t).Interface()
val = fieldValue.Interface()
case reflect.Struct:
if fieldType.ConvertibleTo(schemas.TimeType) {
t := fieldValue.Convert(schemas.TimeType).Interface().(time.Time)

View File

@ -147,7 +147,7 @@ func (statement *Statement) Value2Interface(col *schemas.Column, fieldValue refl
}
return nil, ErrUnSupportedType
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
return int64(fieldValue.Uint()), nil
return fieldValue.Uint(), nil
default:
return fieldValue.Interface(), nil
}