|
@@ -61,7 +61,7 @@ func ParseSqlResult[T any](input any) (T, error) {
|
|
|
if outputType.Kind() == reflect.Struct {
|
|
|
outputEntity = outputValue.Addr().Interface()
|
|
|
} else if outputType.Kind() == reflect.Ptr {
|
|
|
- outputEntity = outputValue.Interface()
|
|
|
+ outputEntity = reflect.New(outputType.Elem()).Interface()
|
|
|
} else {
|
|
|
if outputType.Elem().Kind() == reflect.Struct {
|
|
|
outputEntity = reflect.New(outputType.Elem()).Interface()
|
|
@@ -82,8 +82,14 @@ func ParseSqlResult[T any](input any) (T, error) {
|
|
|
return zero, err
|
|
|
}
|
|
|
|
|
|
- if outputType.Kind() == reflect.Slice {
|
|
|
- outputValue = reflect.Append(outputValue, reflect.ValueOf(outputEntity).Elem())
|
|
|
+ if outputType.Kind() == reflect.Ptr {
|
|
|
+ outputValue = reflect.ValueOf(outputEntity)
|
|
|
+ } else if outputType.Kind() == reflect.Slice {
|
|
|
+ if outputType.Elem().Kind() == reflect.Struct {
|
|
|
+ outputValue = reflect.Append(outputValue, reflect.ValueOf(outputEntity).Elem())
|
|
|
+ } else {
|
|
|
+ outputValue = reflect.Append(outputValue, reflect.ValueOf(outputEntity))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|