From a0ac9992cd57eb41f98172355e562d1f2e74e27b Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Wed, 4 Dec 2013 14:00:39 +0800 Subject: [PATCH] Test use int as primary key --- gorm_test.go | 8 ++++---- utils.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gorm_test.go b/gorm_test.go index ab257f6f..89da4998 100644 --- a/gorm_test.go +++ b/gorm_test.go @@ -36,7 +36,7 @@ type User struct { } type CreditCard struct { - Id int64 + Id int8 Number string UserId sql.NullInt64 CreatedAt time.Time @@ -45,15 +45,15 @@ type CreditCard struct { } type Email struct { - Id int64 - UserId int64 + Id int16 + UserId int Email string `sql:"type:varchar(100); unique"` CreatedAt time.Time UpdatedAt time.Time } type Address struct { - Id int64 + Id int Address1 string Address2 string Post string diff --git a/utils.go b/utils.go index 45d9e800..6ad79420 100644 --- a/utils.go +++ b/utils.go @@ -67,7 +67,7 @@ func toSearchableMap(attrs ...interface{}) (result interface{}) { func setFieldValue(field reflect.Value, value interface{}) bool { if field.IsValid() && field.CanAddr() { switch field.Kind() { - case reflect.Int, reflect.Int32, reflect.Int64: + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: if str, ok := value.(string); ok { value, _ = strconv.Atoi(str) }