fix preload on nil pointer

This commit is contained in:
Aymen 2017-08-21 17:12:01 +01:00
parent c3bb6aaa82
commit 35d9fc7a31

View File

@ -266,6 +266,7 @@ func getValueFromFields(value reflect.Value, fieldNames []string) (results []int
if indirectValue := reflect.Indirect(value); indirectValue.IsValid() {
for _, fieldName := range fieldNames {
if fieldValue := indirectValue.FieldByName(fieldName); fieldValue.IsValid() {
if indirect(fieldValue).IsValid() {
result := fieldValue.Interface()
if r, ok := result.(driver.Valuer); ok {
result, _ = r.Value()
@ -274,6 +275,7 @@ func getValueFromFields(value reflect.Value, fieldNames []string) (results []int
}
}
}
}
return
}