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,11 +266,13 @@ 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() {
result := fieldValue.Interface()
if r, ok := result.(driver.Valuer); ok {
result, _ = r.Value()
if indirect(fieldValue).IsValid() {
result := fieldValue.Interface()
if r, ok := result.(driver.Valuer); ok {
result, _ = r.Value()
}
results = append(results, result)
}
results = append(results, result)
}
}
}