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:
parent
410c2de923
commit
7e981f5f5e
|
@ -797,8 +797,7 @@ func (statement *Statement) buildConds2(table *schemas.Table, bean interface{},
|
||||||
if !requiredField && fieldValue.Uint() == 0 {
|
if !requiredField && fieldValue.Uint() == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t := int64(fieldValue.Uint())
|
val = fieldValue.Interface()
|
||||||
val = reflect.ValueOf(&t).Interface()
|
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
if fieldType.ConvertibleTo(schemas.TimeType) {
|
if fieldType.ConvertibleTo(schemas.TimeType) {
|
||||||
t := fieldValue.Convert(schemas.TimeType).Interface().(time.Time)
|
t := fieldValue.Convert(schemas.TimeType).Interface().(time.Time)
|
||||||
|
|
|
@ -190,8 +190,7 @@ func (statement *Statement) BuildUpdates(tableValue reflect.Value,
|
||||||
if !requiredField && fieldValue.Uint() == 0 {
|
if !requiredField && fieldValue.Uint() == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t := int64(fieldValue.Uint())
|
val = fieldValue.Interface()
|
||||||
val = reflect.ValueOf(&t).Interface()
|
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
if fieldType.ConvertibleTo(schemas.TimeType) {
|
if fieldType.ConvertibleTo(schemas.TimeType) {
|
||||||
t := fieldValue.Convert(schemas.TimeType).Interface().(time.Time)
|
t := fieldValue.Convert(schemas.TimeType).Interface().(time.Time)
|
||||||
|
|
|
@ -147,7 +147,7 @@ func (statement *Statement) Value2Interface(col *schemas.Column, fieldValue refl
|
||||||
}
|
}
|
||||||
return nil, ErrUnSupportedType
|
return nil, ErrUnSupportedType
|
||||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
|
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
|
||||||
return int64(fieldValue.Uint()), nil
|
return fieldValue.Uint(), nil
|
||||||
default:
|
default:
|
||||||
return fieldValue.Interface(), nil
|
return fieldValue.Interface(), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue