Fix AutoMigrate with nested Scanner

This commit is contained in:
Jinzhu 2014-08-04 14:37:51 +08:00
parent 90106d82c5
commit 8308491d9a
1 changed files with 8 additions and 1 deletions

View File

@ -339,7 +339,14 @@ func (scope *Scope) sqlTagForField(field *Field) (typ string) {
} }
case reflect.Struct: case reflect.Struct:
if field.IsScanner() { if field.IsScanner() {
reflectValue = reflectValue.Field(0) var getScannerValue func(reflect.Value)
getScannerValue = func(value reflect.Value) {
reflectValue = value
if _, isScanner := reflect.New(reflectValue.Type()).Interface().(sql.Scanner); isScanner {
getScannerValue(reflectValue.Field(0))
}
}
getScannerValue(reflectValue.Field(0))
} else if !field.IsTime() { } else if !field.IsTime() {
return return
} }