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