From 9d17789b4daa8fb07e9a65786369b0981aa2b524 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 30 Jun 2016 16:55:34 +0800 Subject: [PATCH] resolved #400 --- VERSION | 2 +- session.go | 13 ++++++------- xorm.go | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 5bc5b6c5..a9981730 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -xorm v0.5.4.0513 +xorm v0.5.4.0630 diff --git a/session.go b/session.go index dbcaf195..f6b96192 100644 --- a/session.go +++ b/session.go @@ -3076,7 +3076,7 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) { idByte := res[0][table.AutoIncrement] id, err := strconv.ParseInt(string(idByte), 10, 64) - if err != nil { + if err != nil || id <= 0 { return 1, err } @@ -3085,7 +3085,7 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) { session.Engine.logger.Error(err) } - if aiValue == nil || !aiValue.IsValid() /*|| aiValue. != 0*/ || !aiValue.CanSet() { + if aiValue == nil || !aiValue.IsValid() || !aiValue.CanSet() { return 1, nil } @@ -3121,7 +3121,7 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) { idByte := res[0][table.AutoIncrement] id, err := strconv.ParseInt(string(idByte), 10, 64) - if err != nil { + if err != nil || id <= 0 { return 1, err } @@ -3130,7 +3130,7 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) { session.Engine.logger.Error(err) } - if aiValue == nil || !aiValue.IsValid() /*|| aiValue. != 0*/ || !aiValue.CanSet() { + if aiValue == nil || !aiValue.IsValid() || !aiValue.CanSet() { return 1, nil } @@ -3172,12 +3172,11 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) { session.Engine.logger.Error(err) } - if aiValue == nil || !aiValue.IsValid() /*|| aiValue.Int() != 0*/ || !aiValue.CanSet() { + if aiValue == nil || !aiValue.IsValid() || !aiValue.CanSet() { return res.RowsAffected() } - v := int64ToInt(id, aiValue.Type()) - aiValue.Set(reflect.ValueOf(v)) + aiValue.Set(int64ToIntValue(id, aiValue.Type())) return res.RowsAffected() } diff --git a/xorm.go b/xorm.go index fbe70abc..2115330e 100644 --- a/xorm.go +++ b/xorm.go @@ -17,7 +17,7 @@ import ( const ( // Version show the xorm's version - Version string = "0.5.4.0513" + Version string = "0.5.4.0630" ) func regDrvsNDialects() bool {