func (mwo *MessageWithOptionals) assignValues(columns []string, values []interface{}) error {
	if m, n := len(values), len(columns); m < n {
		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
	}
	for i := range columns {
		switch columns[i] {
		case messagewithoptionals.FieldID:
			value, ok := values[i].(*sql.NullInt64)
			if !ok {
				return fmt.Errorf("unexpected type %T for field id", value)
			}
			mwo.ID = int(value.Int64)
		case messagewithoptionals.FieldStrOptional:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field str_optional", values[i])
			} else if value.Valid {
				mwo.StrOptional = value.String
			}
		case messagewithoptionals.FieldIntOptional:
			if value, ok := values[i].(*sql.NullInt64); !ok {
				return fmt.Errorf("unexpected type %T for field int_optional", values[i])
			} else if value.Valid {
				mwo.IntOptional = int8(value.Int64)
			}
		case messagewithoptionals.FieldUintOptional:
			if value, ok := values[i].(*sql.NullInt64); !ok {
				return fmt.Errorf("unexpected type %T for field uint_optional", values[i])
			} else if value.Valid {
				mwo.UintOptional = uint8(value.Int64)
			}
		case messagewithoptionals.FieldFloatOptional:
			if value, ok := values[i].(*sql.NullFloat64); !ok {
				return fmt.Errorf("unexpected type %T for field float_optional", values[i])
			} else if value.Valid {
				mwo.FloatOptional = float32(value.Float64)
			}
		case messagewithoptionals.FieldBoolOptional:
			if value, ok := values[i].(*sql.NullBool); !ok {
				return fmt.Errorf("unexpected type %T for field bool_optional", values[i])
			} else if value.Valid {
				mwo.BoolOptional = value.Bool
			}
		case messagewithoptionals.FieldBytesOptional:
			if value, ok := values[i].(*[]byte); !ok {
				return fmt.Errorf("unexpected type %T for field bytes_optional", values[i])
			} else if value != nil {
				mwo.BytesOptional = *value
			}
		case messagewithoptionals.FieldUUIDOptional:
			if value, ok := values[i].(*uuid.UUID); !ok {
				return fmt.Errorf("unexpected type %T for field uuid_optional", values[i])
			} else if value != nil {
				mwo.UUIDOptional = *value
			}
		case messagewithoptionals.FieldTimeOptional:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field time_optional", values[i])
			} else if value.Valid {
				mwo.TimeOptional = value.Time
			}
		}
	}
	return nil
}
assignValues assigns the values that were returned from sql.Rows (after scanning)
to the MessageWithOptionals fields.
package ent
import (
	"fmt"
	"strings"
	"time"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithoptionals"
	"entgo.io/ent/dialect/sql"
	"github.com/google/uuid"
)
type MessageWithOptionals struct {
	config `json:"-"`
	ID int `json:"id,omitempty"`
	StrOptional string `json:"str_optional,omitempty"`
	IntOptional int8 `json:"int_optional,omitempty"`
	UintOptional uint8 `json:"uint_optional,omitempty"`
	FloatOptional float32 `json:"float_optional,omitempty"`
	BoolOptional bool `json:"bool_optional,omitempty"`
	BytesOptional []byte `json:"bytes_optional,omitempty"`
	UUIDOptional uuid.UUID `json:"uuid_optional,omitempty"`
	TimeOptional time.Time `json:"time_optional,omitempty"`
}
func (*MessageWithOptionals) scanValues(columns []string) ([]interface{}, error) {
	values := make([]interface{}, len(columns))
	for i := range columns {
		switch columns[i] {
		case messagewithoptionals.FieldBytesOptional:
			values[i] = new([]byte)
		case messagewithoptionals.FieldBoolOptional:
			values[i] = new(sql.NullBool)
		case messagewithoptionals.FieldFloatOptional:
			values[i] = new(sql.NullFloat64)
		case messagewithoptionals.FieldID, messagewithoptionals.FieldIntOptional, messagewithoptionals.FieldUintOptional:
			values[i] = new(sql.NullInt64)
		case messagewithoptionals.FieldStrOptional:
			values[i] = new(sql.NullString)
		case messagewithoptionals.FieldTimeOptional:
			values[i] = new(sql.NullTime)
		case messagewithoptionals.FieldUUIDOptional:
			values[i] = new(uuid.UUID)
		default:
			return nil, fmt.Errorf("unexpected column %q for type MessageWithOptionals", columns[i])
		}
	}
	return values, nil
}