forked from mirror/gorm
Fix all tests
This commit is contained in:
parent
d6439f4147
commit
a38f83527a
|
@ -103,7 +103,11 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
|
||||||
if reflectValue.Kind() == reflect.Slice {
|
if reflectValue.Kind() == reflect.Slice {
|
||||||
reflectValue = reflect.Indirect(reflect.New(reflectValue.Type().Elem()))
|
reflectValue = reflect.Indirect(reflect.New(reflectValue.Type().Elem()))
|
||||||
}
|
}
|
||||||
|
|
||||||
scopeType := reflectValue.Type()
|
scopeType := reflectValue.Type()
|
||||||
|
if scopeType.Kind() == reflect.Ptr {
|
||||||
|
scopeType = scopeType.Elem()
|
||||||
|
}
|
||||||
|
|
||||||
if scopeType.Kind() != reflect.Struct {
|
if scopeType.Kind() != reflect.Struct {
|
||||||
return &modelStruct
|
return &modelStruct
|
||||||
|
|
2
scope.go
2
scope.go
|
@ -96,7 +96,7 @@ func (scope *Scope) HasError() bool {
|
||||||
|
|
||||||
func (scope *Scope) PrimaryKeyField() *Field {
|
func (scope *Scope) PrimaryKeyField() *Field {
|
||||||
if field := scope.GetModelStruct().PrimaryKeyField; field != nil {
|
if field := scope.GetModelStruct().PrimaryKeyField; field != nil {
|
||||||
return scope.getField(field)
|
return scope.Fields()[field.DBName]
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue