forked from mirror/gorm
Fix invalid reflect value
This commit is contained in:
parent
febc826511
commit
07e2d49b22
3
scope.go
3
scope.go
|
@ -267,6 +267,9 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) *Field {
|
||||||
|
|
||||||
if !field.IsIgnored {
|
if !field.IsIgnored {
|
||||||
// parse association
|
// parse association
|
||||||
|
if !indirectValue.IsValid() {
|
||||||
|
indirectValue = reflect.New(value.Type())
|
||||||
|
}
|
||||||
typ := indirectValue.Type()
|
typ := indirectValue.Type()
|
||||||
foreignKey := SnakeToUpperCamel(settings["FOREIGNKEY"])
|
foreignKey := SnakeToUpperCamel(settings["FOREIGNKEY"])
|
||||||
associationForeignKey := SnakeToUpperCamel(settings["ASSOCIATIONFOREIGNKEY"])
|
associationForeignKey := SnakeToUpperCamel(settings["ASSOCIATIONFOREIGNKEY"])
|
||||||
|
|
|
@ -32,6 +32,7 @@ type User struct {
|
||||||
IgnoreMe int64 `sql:"-"`
|
IgnoreMe int64 `sql:"-"`
|
||||||
IgnoreStringSlice []string `sql:"-"`
|
IgnoreStringSlice []string `sql:"-"`
|
||||||
Ignored struct{ Name string } `sql:"-"`
|
Ignored struct{ Name string } `sql:"-"`
|
||||||
|
IgnoredPointer *User `sql:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreditCard struct {
|
type CreditCard struct {
|
||||||
|
|
Loading…
Reference in New Issue