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