Fix pointers for AutoMigrate

This commit is contained in:
Jinzhu 2015-02-09 21:14:48 +08:00
parent b33f30714b
commit 9757958106
2 changed files with 8 additions and 1 deletions

View File

@ -34,7 +34,11 @@ func (field *Field) IsScanner() bool {
} }
func (field *Field) IsTime() bool { func (field *Field) IsTime() bool {
_, isTime := field.Field.Interface().(time.Time) reflectValue := field.Field
if reflectValue.Kind() == reflect.Ptr {
reflectValue = reflect.New(reflectValue.Type().Elem()).Elem()
}
_, isTime := reflectValue.Interface().(time.Time)
return isTime return isTime
} }

View File

@ -393,6 +393,9 @@ func (scope *Scope) sqlTagForField(field *Field) (typ string) {
value := field.Field.Interface() value := field.Field.Interface()
reflectValue := field.Field reflectValue := field.Field
if reflectValue.Kind() == reflect.Ptr {
reflectValue = reflect.New(reflectValue.Type().Elem()).Elem()
}
switch reflectValue.Kind() { switch reflectValue.Kind() {
case reflect.Slice: case reflect.Slice: