func (mwegb *MessageWithEnumGroupBy) String(ctx context.Context) (_ string, err error) {
	var v []string
	if v, err = mwegb.Strings(ctx); err != nil {
		return
	}
	switch len(v) {
	case 1:
		return v[0], nil
	case 0:
		err = &NotFoundError{messagewithenum.Label}
	default:
		err = fmt.Errorf("ent: MessageWithEnumGroupBy.Strings returned %d results when one was expected", len(v))
	}
	return
}
String returns a single string from a group-by query.
It is only allowed when executing a group-by query with one field.
package ent
import (
	"context"
	"errors"
	"fmt"
	"math"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithenum"
	"entgo.io/contrib/entproto/internal/entprototest/ent/predicate"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type MessageWithEnumQuery struct {
	config
	limit      *int
	offset     *int
	unique     *bool
	order      []OrderFunc
	fields     []string
	predicates []predicate.MessageWithEnum
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (mweq *MessageWithEnumQuery) Where(ps ...predicate.MessageWithEnum) *MessageWithEnumQuery {
	mweq.predicates = append(mweq.predicates, ps...)
	return mweq
}
func (mweq *MessageWithEnumQuery) Limit(limit int) *MessageWithEnumQuery {
	mweq.limit = &limit
	return mweq
}
func (mweq *MessageWithEnumQuery) Offset(offset int) *MessageWithEnumQuery {
	mweq.offset = &offset
	return mweq
}
func (mweq *MessageWithEnumQuery) Unique(unique bool) *MessageWithEnumQuery {
	mweq.unique = &unique
	return mweq
}
func (mweq *MessageWithEnumQuery) Order(o ...OrderFunc) *MessageWithEnumQuery {
	mweq.order = append(mweq.order, o...)
	return mweq
}
func (mweq *MessageWithEnumQuery) First(ctx context.Context) (*MessageWithEnum, error) {
	nodes, err := mweq.Limit(1).All(ctx)
	if err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nil, &NotFoundError{messagewithenum.Label}
	}
	return nodes[0], nil
}
func (mweq *MessageWithEnumQuery) FirstX(ctx context.Context) *MessageWithEnum {
	node, err := mweq.First(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return node
}
func (mweq *MessageWithEnumQuery) FirstID(ctx context.Context) (id int, err error) {
	var ids []int
	if ids, err = mweq.Limit(1).IDs(ctx); err != nil {
		return
	}
	if len(ids) == 0 {
		err = &NotFoundError{messagewithenum.Label}
		return
	}
	return ids[0], nil
}
func (mweq *MessageWithEnumQuery) FirstIDX(ctx context.Context) int {
	id, err := mweq.FirstID(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return id
}
func (mweq *MessageWithEnumQuery) Only(ctx context.Context) (*MessageWithEnum, error) {
	nodes, err := mweq.Limit(2).All(ctx)
	if err != nil {
		return nil, err
	}
	switch len(nodes) {
	case 1:
		return nodes[0], nil
	case 0:
		return nil, &NotFoundError{messagewithenum.Label}
	default:
		return nil, &NotSingularError{messagewithenum.Label}
	}
}
func (mweq *MessageWithEnumQuery) OnlyX(ctx context.Context) *MessageWithEnum {
	node, err := mweq.Only(ctx)
	if err != nil {
		panic(err)
	}
	return node
}
func (mweq *MessageWithEnumQuery) OnlyID(ctx context.Context) (id int, err error) {
	var ids []int
	if ids, err = mweq.Limit(2).IDs(ctx); err != nil {
		return
	}
	switch len(ids) {
	case 1:
		id = ids[0]
	case 0:
		err = &NotFoundError{messagewithenum.Label}
	default:
		err = &NotSingularError{messagewithenum.Label}
	}
	return
}
func (mweq *MessageWithEnumQuery) OnlyIDX(ctx context.Context) int {
	id, err := mweq.OnlyID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}
func (mweq *MessageWithEnumQuery) All(ctx context.Context) ([]*MessageWithEnum, error) {
	if err := mweq.prepareQuery(ctx); err != nil {
		return nil, err
	}
	return mweq.sqlAll(ctx)
}
func (mweq *MessageWithEnumQuery) AllX(ctx context.Context) []*MessageWithEnum {
	nodes, err := mweq.All(ctx)
	if err != nil {
		panic(err)
	}
	return nodes
}
func (mweq *MessageWithEnumQuery) IDs(ctx context.Context) ([]int, error) {
	var ids []int
	if err := mweq.Select(messagewithenum.FieldID).Scan(ctx, &ids); err != nil {
		return nil, err
	}
	return ids, nil
}
func (mweq *MessageWithEnumQuery) IDsX(ctx context.Context) []int {
	ids, err := mweq.IDs(ctx)
	if err != nil {
		panic(err)
	}
	return ids
}
func (mweq *MessageWithEnumQuery) Count(ctx context.Context) (int, error) {
	if err := mweq.prepareQuery(ctx); err != nil {
		return 0, err
	}
	return mweq.sqlCount(ctx)
}
func (mweq *MessageWithEnumQuery) CountX(ctx context.Context) int {
	count, err := mweq.Count(ctx)
	if err != nil {
		panic(err)
	}
	return count
}
func (mweq *MessageWithEnumQuery) Exist(ctx context.Context) (bool, error) {
	if err := mweq.prepareQuery(ctx); err != nil {
		return false, err
	}
	return mweq.sqlExist(ctx)
}
func (mweq *MessageWithEnumQuery) ExistX(ctx context.Context) bool {
	exist, err := mweq.Exist(ctx)
	if err != nil {
		panic(err)
	}
	return exist
}
func (mweq *MessageWithEnumQuery) Clone() *MessageWithEnumQuery {
	if mweq == nil {
		return nil
	}
	return &MessageWithEnumQuery{
		config:     mweq.config,
		limit:      mweq.limit,
		offset:     mweq.offset,
		order:      append([]OrderFunc{}, mweq.order...),
		predicates: append([]predicate.MessageWithEnum{}, mweq.predicates...),
		sql:  mweq.sql.Clone(),
		path: mweq.path,
	}
}
func (mweq *MessageWithEnumQuery) GroupBy(field string, fields ...string) *MessageWithEnumGroupBy {
	group := &MessageWithEnumGroupBy{config: mweq.config}
	group.fields = append([]string{field}, fields...)
	group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
		if err := mweq.prepareQuery(ctx); err != nil {
			return nil, err
		}
		return mweq.sqlQuery(ctx), nil
	}
	return group
}
func (mweq *MessageWithEnumQuery) Select(fields ...string) *MessageWithEnumSelect {
	mweq.fields = append(mweq.fields, fields...)
	return &MessageWithEnumSelect{MessageWithEnumQuery: mweq}
}
func (mweq *MessageWithEnumQuery) prepareQuery(ctx context.Context) error {
	for _, f := range mweq.fields {
		if !messagewithenum.ValidColumn(f) {
			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
		}
	}
	if mweq.path != nil {
		prev, err := mweq.path(ctx)
		if err != nil {
			return err
		}
		mweq.sql = prev
	}
	return nil
}
func (mweq *MessageWithEnumQuery) sqlAll(ctx context.Context) ([]*MessageWithEnum, error) {
	var (
		nodes = []*MessageWithEnum{}
		_spec = mweq.querySpec()
	)
	_spec.ScanValues = func(columns []string) ([]interface{}, error) {
		node := &MessageWithEnum{config: mweq.config}
		nodes = append(nodes, node)
		return node.scanValues(columns)
	}
	_spec.Assign = func(columns []string, values []interface{}) error {
		if len(nodes) == 0 {
			return fmt.Errorf("ent: Assign called without calling ScanValues")
		}
		node := nodes[len(nodes)-1]
		return node.assignValues(columns, values)
	}
	if err := sqlgraph.QueryNodes(ctx, mweq.driver, _spec); err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nodes, nil
	}
	return nodes, nil
}
func (mweq *MessageWithEnumQuery) sqlCount(ctx context.Context) (int, error) {
	_spec := mweq.querySpec()
	return sqlgraph.CountNodes(ctx, mweq.driver, _spec)
}
func (mweq *MessageWithEnumQuery) sqlExist(ctx context.Context) (bool, error) {
	n, err := mweq.sqlCount(ctx)
	if err != nil {
		return false, fmt.Errorf("ent: check existence: %w", err)
	}
	return n > 0, nil
}
func (mweq *MessageWithEnumQuery) querySpec() *sqlgraph.QuerySpec {
	_spec := &sqlgraph.QuerySpec{
		Node: &sqlgraph.NodeSpec{
			Table:   messagewithenum.Table,
			Columns: messagewithenum.Columns,
			ID: &sqlgraph.FieldSpec{
				Type:   field.TypeInt,
				Column: messagewithenum.FieldID,
			},
		},
		From:   mweq.sql,
		Unique: true,
	}
	if unique := mweq.unique; unique != nil {
		_spec.Unique = *unique
	}
	if fields := mweq.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, messagewithenum.FieldID)
		for i := range fields {
			if fields[i] != messagewithenum.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
			}
		}
	}
	if ps := mweq.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if limit := mweq.limit; limit != nil {
		_spec.Limit = *limit
	}
	if offset := mweq.offset; offset != nil {
		_spec.Offset = *offset
	}
	if ps := mweq.order; len(ps) > 0 {
		_spec.Order = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	return _spec
}
func (mweq *MessageWithEnumQuery) sqlQuery(ctx context.Context) *sql.Selector {
	builder := sql.Dialect(mweq.driver.Dialect())
	t1 := builder.Table(messagewithenum.Table)
	columns := mweq.fields
	if len(columns) == 0 {
		columns = messagewithenum.Columns
	}
	selector := builder.Select(t1.Columns(columns...)...).From(t1)
	if mweq.sql != nil {
		selector = mweq.sql
		selector.Select(selector.Columns(columns...)...)
	}
	for _, p := range mweq.predicates {
		p(selector)
	}
	for _, p := range mweq.order {
		p(selector)
	}
	if offset := mweq.offset; offset != nil {
		selector.Offset(*offset).Limit(math.MaxInt32)
	}
	if limit := mweq.limit; limit != nil {
		selector.Limit(*limit)
	}
	return selector
}
type MessageWithEnumGroupBy struct {
	config
	fields []string
	fns    []AggregateFunc
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (mwegb *MessageWithEnumGroupBy) Aggregate(fns ...AggregateFunc) *MessageWithEnumGroupBy {
	mwegb.fns = append(mwegb.fns, fns...)
	return mwegb
}
func (mwegb *MessageWithEnumGroupBy) Scan(ctx context.Context, v interface{}) error {
	query, err := mwegb.path(ctx)
	if err != nil {
		return err
	}
	mwegb.sql = query
	return mwegb.sqlScan(ctx, v)
}
func (mwegb *MessageWithEnumGroupBy) ScanX(ctx context.Context, v interface{}) {
	if err := mwegb.Scan(ctx, v); err != nil {
		panic(err)
	}
}
func (mwegb *MessageWithEnumGroupBy) Strings(ctx context.Context) ([]string, error) {
	if len(mwegb.fields) > 1 {
		return nil, errors.New("ent: MessageWithEnumGroupBy.Strings is not achievable when grouping more than 1 field")
	}
	var v []string
	if err := mwegb.Scan(ctx, &v); err != nil {
		return nil, err
	}
	return v, nil
}
func (mwegb *MessageWithEnumGroupBy) StringsX(ctx context.Context) []string {
	v, err := mwegb.Strings(ctx)
	if err != nil {
		panic(err)
	}
	return v
}