Fix all tests

This commit is contained in:
Jinzhu 2015-02-17 18:37:47 +08:00
parent d6439f4147
commit a38f83527a
2 changed files with 5 additions and 1 deletions

View File

@ -103,7 +103,11 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
if reflectValue.Kind() == reflect.Slice {
reflectValue = reflect.Indirect(reflect.New(reflectValue.Type().Elem()))
}
scopeType := reflectValue.Type()
if scopeType.Kind() == reflect.Ptr {
scopeType = scopeType.Elem()
}
if scopeType.Kind() != reflect.Struct {
return &modelStruct

View File

@ -96,7 +96,7 @@ func (scope *Scope) HasError() bool {
func (scope *Scope) PrimaryKeyField() *Field {
if field := scope.GetModelStruct().PrimaryKeyField; field != nil {
return scope.getField(field)
return scope.Fields()[field.DBName]
}
return nil
}