Test use int as primary key

This commit is contained in:
Jinzhu 2013-12-04 14:00:39 +08:00
parent fb65095376
commit a0ac9992cd
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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)
}