func (mwigb *MessageWithIDGroupBy) StringX(ctx context.Context) string {
	v, err := mwigb.String(ctx)
	if err != nil {
		panic(err)
	}
	return v
}
StringX is like String, but panics if an error occurs.
package ent
import (
	"context"
	"errors"
	"fmt"
	"math"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithid"
	"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 MessageWithIDQuery struct {
	config
	limit      *int
	offset     *int
	unique     *bool
	order      []OrderFunc
	fields     []string
	predicates []predicate.MessageWithID
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (mwiq *MessageWithIDQuery) Where(ps ...predicate.MessageWithID) *MessageWithIDQuery {
	mwiq.predicates = append(mwiq.predicates, ps...)
	return mwiq
}
func (mwiq *MessageWithIDQuery) Limit(limit int) *MessageWithIDQuery {
	mwiq.limit = &limit
	return mwiq
}
func (mwiq *MessageWithIDQuery) Offset(offset int) *MessageWithIDQuery {
	mwiq.offset = &offset
	return mwiq
}
func (mwiq *MessageWithIDQuery) Unique(unique bool) *MessageWithIDQuery {
	mwiq.unique = &unique
	return mwiq
}
func (mwiq *MessageWithIDQuery) Order(o ...OrderFunc) *MessageWithIDQuery {
	mwiq.order = append(mwiq.order, o...)
	return mwiq
}
func (mwiq *MessageWithIDQuery) First(ctx context.Context) (*MessageWithID, error) {
	nodes, err := mwiq.Limit(1).All(ctx)
	if err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nil, &NotFoundError{messagewithid.Label}
	}
	return nodes[0], nil
}
func (mwiq *MessageWithIDQuery) FirstX(ctx context.Context) *MessageWithID {
	node, err := mwiq.First(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return node
}
func (mwiq *MessageWithIDQuery) FirstID(ctx context.Context) (id int32, err error) {
	var ids []int32
	if ids, err = mwiq.Limit(1).IDs(ctx); err != nil {
		return
	}
	if len(ids) == 0 {
		err = &NotFoundError{messagewithid.Label}
		return
	}
	return ids[0], nil
}
func (mwiq *MessageWithIDQuery) FirstIDX(ctx context.Context) int32 {
	id, err := mwiq.FirstID(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return id
}
func (mwiq *MessageWithIDQuery) Only(ctx context.Context) (*MessageWithID, error) {
	nodes, err := mwiq.Limit(2).All(ctx)
	if err != nil {
		return nil, err
	}
	switch len(nodes) {
	case 1:
		return nodes[0], nil
	case 0:
		return nil, &NotFoundError{messagewithid.Label}
	default:
		return nil, &NotSingularError{messagewithid.Label}
	}
}
func (mwiq *MessageWithIDQuery) OnlyX(ctx context.Context) *MessageWithID {
	node, err := mwiq.Only(ctx)
	if err != nil {
		panic(err)
	}
	return node
}
func (mwiq *MessageWithIDQuery) OnlyID(ctx context.Context) (id int32, err error) {
	var ids []int32
	if ids, err = mwiq.Limit(2).IDs(ctx); err != nil {
		return
	}
	switch len(ids) {
	case 1:
		id = ids[0]
	case 0:
		err = &NotFoundError{messagewithid.Label}
	default:
		err = &NotSingularError{messagewithid.Label}
	}
	return
}
func (mwiq *MessageWithIDQuery) OnlyIDX(ctx context.Context) int32 {
	id, err := mwiq.OnlyID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}
func (mwiq *MessageWithIDQuery) All(ctx context.Context) ([]*MessageWithID, error) {
	if err := mwiq.prepareQuery(ctx); err != nil {
		return nil, err
	}
	return mwiq.sqlAll(ctx)
}
func (mwiq *MessageWithIDQuery) AllX(ctx context.Context) []*MessageWithID {
	nodes, err := mwiq.All(ctx)
	if err != nil {
		panic(err)
	}
	return nodes
}
func (mwiq *MessageWithIDQuery) IDs(ctx context.Context) ([]int32, error) {
	var ids []int32
	if err := mwiq.Select(messagewithid.FieldID).Scan(ctx, &ids); err != nil {
		return nil, err
	}
	return ids, nil
}
func (mwiq *MessageWithIDQuery) IDsX(ctx context.Context) []int32 {
	ids, err := mwiq.IDs(ctx)
	if err != nil {
		panic(err)
	}
	return ids
}
func (mwiq *MessageWithIDQuery) Count(ctx context.Context) (int, error) {
	if err := mwiq.prepareQuery(ctx); err != nil {
		return 0, err
	}
	return mwiq.sqlCount(ctx)
}
func (mwiq *MessageWithIDQuery) CountX(ctx context.Context) int {
	count, err := mwiq.Count(ctx)
	if err != nil {
		panic(err)
	}
	return count
}
func (mwiq *MessageWithIDQuery) Exist(ctx context.Context) (bool, error) {
	if err := mwiq.prepareQuery(ctx); err != nil {
		return false, err
	}
	return mwiq.sqlExist(ctx)
}
func (mwiq *MessageWithIDQuery) ExistX(ctx context.Context) bool {
	exist, err := mwiq.Exist(ctx)
	if err != nil {
		panic(err)
	}
	return exist
}
func (mwiq *MessageWithIDQuery) Clone() *MessageWithIDQuery {
	if mwiq == nil {
		return nil
	}
	return &MessageWithIDQuery{
		config:     mwiq.config,
		limit:      mwiq.limit,
		offset:     mwiq.offset,
		order:      append([]OrderFunc{}, mwiq.order...),
		predicates: append([]predicate.MessageWithID{}, mwiq.predicates...),
		sql:  mwiq.sql.Clone(),
		path: mwiq.path,
	}
}
func (mwiq *MessageWithIDQuery) GroupBy(field string, fields ...string) *MessageWithIDGroupBy {
	group := &MessageWithIDGroupBy{config: mwiq.config}
	group.fields = append([]string{field}, fields...)
	group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
		if err := mwiq.prepareQuery(ctx); err != nil {
			return nil, err
		}
		return mwiq.sqlQuery(ctx), nil
	}
	return group
}
func (mwiq *MessageWithIDQuery) Select(fields ...string) *MessageWithIDSelect {
	mwiq.fields = append(mwiq.fields, fields...)
	return &MessageWithIDSelect{MessageWithIDQuery: mwiq}
}
func (mwiq *MessageWithIDQuery) prepareQuery(ctx context.Context) error {
	for _, f := range mwiq.fields {
		if !messagewithid.ValidColumn(f) {
			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
		}
	}
	if mwiq.path != nil {
		prev, err := mwiq.path(ctx)
		if err != nil {
			return err
		}
		mwiq.sql = prev
	}
	return nil
}
func (mwiq *MessageWithIDQuery) sqlAll(ctx context.Context) ([]*MessageWithID, error) {
	var (
		nodes = []*MessageWithID{}
		_spec = mwiq.querySpec()
	)
	_spec.ScanValues = func(columns []string) ([]interface{}, error) {
		node := &MessageWithID{config: mwiq.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, mwiq.driver, _spec); err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nodes, nil
	}
	return nodes, nil
}
func (mwiq *MessageWithIDQuery) sqlCount(ctx context.Context) (int, error) {
	_spec := mwiq.querySpec()
	return sqlgraph.CountNodes(ctx, mwiq.driver, _spec)
}
func (mwiq *MessageWithIDQuery) sqlExist(ctx context.Context) (bool, error) {
	n, err := mwiq.sqlCount(ctx)
	if err != nil {
		return false, fmt.Errorf("ent: check existence: %w", err)
	}
	return n > 0, nil
}
func (mwiq *MessageWithIDQuery) querySpec() *sqlgraph.QuerySpec {
	_spec := &sqlgraph.QuerySpec{
		Node: &sqlgraph.NodeSpec{
			Table:   messagewithid.Table,
			Columns: messagewithid.Columns,
			ID: &sqlgraph.FieldSpec{
				Type:   field.TypeInt32,
				Column: messagewithid.FieldID,
			},
		},
		From:   mwiq.sql,
		Unique: true,
	}
	if unique := mwiq.unique; unique != nil {
		_spec.Unique = *unique
	}
	if fields := mwiq.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, messagewithid.FieldID)
		for i := range fields {
			if fields[i] != messagewithid.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
			}
		}
	}
	if ps := mwiq.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if limit := mwiq.limit; limit != nil {
		_spec.Limit = *limit
	}
	if offset := mwiq.offset; offset != nil {
		_spec.Offset = *offset
	}
	if ps := mwiq.order; len(ps) > 0 {
		_spec.Order = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	return _spec
}
func (mwiq *MessageWithIDQuery) sqlQuery(ctx context.Context) *sql.Selector {
	builder := sql.Dialect(mwiq.driver.Dialect())
	t1 := builder.Table(messagewithid.Table)
	columns := mwiq.fields
	if len(columns) == 0 {
		columns = messagewithid.Columns
	}
	selector := builder.Select(t1.Columns(columns...)...).From(t1)
	if mwiq.sql != nil {
		selector = mwiq.sql
		selector.Select(selector.Columns(columns...)...)
	}
	for _, p := range mwiq.predicates {
		p(selector)
	}
	for _, p := range mwiq.order {
		p(selector)
	}
	if offset := mwiq.offset; offset != nil {
		selector.Offset(*offset).Limit(math.MaxInt32)
	}
	if limit := mwiq.limit; limit != nil {
		selector.Limit(*limit)
	}
	return selector
}
type MessageWithIDGroupBy struct {
	config
	fields []string
	fns    []AggregateFunc
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (mwigb *MessageWithIDGroupBy) Aggregate(fns ...AggregateFunc) *MessageWithIDGroupBy {
	mwigb.fns = append(mwigb.fns, fns...)
	return mwigb
}
func (mwigb *MessageWithIDGroupBy) Scan(ctx context.Context, v interface{}) error {
	query, err := mwigb.path(ctx)
	if err != nil {
		return err
	}
	mwigb.sql = query
	return mwigb.sqlScan(ctx, v)
}
func (mwigb *MessageWithIDGroupBy) ScanX(ctx context.Context, v interface{}) {
	if err := mwigb.Scan(ctx, v); err != nil {
		panic(err)
	}
}
func (mwigb *MessageWithIDGroupBy) Strings(ctx context.Context) ([]string, error) {
	if len(mwigb.fields) > 1 {
		return nil, errors.New("ent: MessageWithIDGroupBy.Strings is not achievable when grouping more than 1 field")
	}
	var v []string
	if err := mwigb.Scan(ctx, &v); err != nil {
		return nil, err
	}
	return v, nil
}
func (mwigb *MessageWithIDGroupBy) StringsX(ctx context.Context) []string {
	v, err := mwigb.Strings(ctx)
	if err != nil {
		panic(err)
	}
	return v
}
func (mwigb *MessageWithIDGroupBy) String(ctx context.Context) (_ string, err error) {
	var v []string
	if v, err = mwigb.Strings(ctx); err != nil {
		return
	}
	switch len(v) {
	case 1:
		return v[0], nil
	case 0:
		err = &NotFoundError{messagewithid.Label}
	default:
		err = fmt.Errorf("ent: MessageWithIDGroupBy.Strings returned %d results when one was expected", len(v))
	}
	return
}