package sqlutil

import (
	"database/sql"
	"reflect"
)

func ColumnValues(columns []*sql.ColumnType) []interface{} {

	values := make([]interface{}, len(columns))
	for i, column := range columns {
		switch column.ScanType().Kind() {
		case reflect.Int64:
			values[i] = &sql.NullInt64{}
		case reflect.Int32:
			values[i] = &sql.NullInt32{}
		case reflect.Bool:
			values[i] = &sql.NullBool{}
		case reflect.String:
			values[i] = &sql.NullString{}
		case reflect.Struct:
			if column.ScanType().String() == "time.Time" {
				values[i] = &sql.NullTime{}
			}
		case reflect.Slice:
			if column.ScanType().String() == "sql.RawBytes" {
				values[i] = &sql.NullString{}
			}
		default:
			values[i] = &sql.NullFloat64{}
		}
	}

	return values
}
