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 {
|
type CreditCard struct {
|
||||||
Id int64
|
Id int8
|
||||||
Number string
|
Number string
|
||||||
UserId sql.NullInt64
|
UserId sql.NullInt64
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
|
@ -45,15 +45,15 @@ type CreditCard struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Email struct {
|
type Email struct {
|
||||||
Id int64
|
Id int16
|
||||||
UserId int64
|
UserId int
|
||||||
Email string `sql:"type:varchar(100); unique"`
|
Email string `sql:"type:varchar(100); unique"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type Address struct {
|
type Address struct {
|
||||||
Id int64
|
Id int
|
||||||
Address1 string
|
Address1 string
|
||||||
Address2 string
|
Address2 string
|
||||||
Post 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 {
|
func setFieldValue(field reflect.Value, value interface{}) bool {
|
||||||
if field.IsValid() && field.CanAddr() {
|
if field.IsValid() && field.CanAddr() {
|
||||||
switch field.Kind() {
|
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 {
|
if str, ok := value.(string); ok {
|
||||||
value, _ = strconv.Atoi(str)
|
value, _ = strconv.Atoi(str)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue