fix bug for mis-converting uint64 to int64

This commit is contained in:
rosbit 2020-04-04 11:36:09 +08:00
parent 410c2de923
commit 30bb1d6ba0
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
}