Fix invalid reflect value

This commit is contained in:
Jinzhu 2014-08-15 11:14:33 +08:00
parent febc826511
commit 07e2d49b22
2 changed files with 4 additions and 0 deletions

View File

@ -267,6 +267,9 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) *Field {
if !field.IsIgnored {
// parse association
if !indirectValue.IsValid() {
indirectValue = reflect.New(value.Type())
}
typ := indirectValue.Type()
foreignKey := SnakeToUpperCamel(settings["FOREIGNKEY"])
associationForeignKey := SnakeToUpperCamel(settings["ASSOCIATIONFOREIGNKEY"])

View File

@ -32,6 +32,7 @@ type User struct {
IgnoreMe int64 `sql:"-"`
IgnoreStringSlice []string `sql:"-"`
Ignored struct{ Name string } `sql:"-"`
IgnoredPointer *User `sql:"-"`
}
type CreditCard struct {