From c9db8e93f7c2c5df8050cb0da244377a89f8877f Mon Sep 17 00:00:00 2001 From: Nicolas Duval Date: Fri, 11 Jul 2014 10:40:41 -0700 Subject: [PATCH] Support uint64 with high bit set. This limitation is due to "database/sql" go package implementation. --- session.go | 2 ++ statement.go | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/session.go b/session.go index 222d398c..f4394abc 100644 --- a/session.go +++ b/session.go @@ -2597,6 +2597,8 @@ func (session *Session) value2Interface(col *core.Column, fieldValue reflect.Val } else { return nil, ErrUnSupportedType } + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + return int64(fieldValue.Uint()), nil default: return fieldValue.Interface(), nil } diff --git a/statement.go b/statement.go index 28b0d0dc..d872e267 100644 --- a/statement.go +++ b/statement.go @@ -375,7 +375,8 @@ func buildUpdates(engine *Engine, table *core.Table, bean interface{}, if !requiredField && fieldValue.Uint() == 0 { continue } - val = fieldValue.Interface() + t := int64(fieldValue.Uint()) + val = reflect.ValueOf(&t).Interface() case reflect.Struct: if fieldType == reflect.TypeOf(time.Now()) { t := fieldValue.Interface().(time.Time) @@ -546,7 +547,8 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{}, if !requiredField && fieldValue.Uint() == 0 { continue } - val = fieldValue.Interface() + t := int64(fieldValue.Uint()) + val = reflect.ValueOf(&t).Interface() case reflect.Struct: if fieldType == reflect.TypeOf(time.Now()) { t := fieldValue.Interface().(time.Time)