mirror of https://github.com/go-gorm/gorm.git
Test use int as primary key
This commit is contained in:
parent
fb65095376
commit
a0ac9992cd
|
@ -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
|
||||
|
|
2
utils.go
2
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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue