func (ifmgb *InvalidFieldMessageGroupBy) Scan(ctx context.Context, v interface{}) error {
	query, err := ifmgb.path(ctx)
	if err != nil {
		return err
	}
	ifmgb.sql = query
	return ifmgb.sqlScan(ctx, v)
}
Scan applies the group-by query and scans the result into the given value.
package ent
import (
	"context"
	"errors"
	"fmt"
	"math"
	"entgo.io/contrib/entproto/internal/entprototest/ent/invalidfieldmessage"
	"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 InvalidFieldMessageQuery struct {
	config
	limit      *int
	offset     *int
	unique     *bool
	order      []OrderFunc
	fields     []string
	predicates []predicate.InvalidFieldMessage
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (ifmq *InvalidFieldMessageQuery) Where(ps ...predicate.InvalidFieldMessage) *InvalidFieldMessageQuery {
	ifmq.predicates = append(ifmq.predicates, ps...)
	return ifmq
}
func (ifmq *InvalidFieldMessageQuery) Limit(limit int) *InvalidFieldMessageQuery {
	ifmq.limit = &limit
	return ifmq
}
func (ifmq *InvalidFieldMessageQuery) Offset(offset int) *InvalidFieldMessageQuery {
	ifmq.offset = &offset
	return ifmq
}
func (ifmq *InvalidFieldMessageQuery) Unique(unique bool) *InvalidFieldMessageQuery {
	ifmq.unique = &unique
	return ifmq
}
func (ifmq *InvalidFieldMessageQuery) Order(o ...OrderFunc) *InvalidFieldMessageQuery {
	ifmq.order = append(ifmq.order, o...)
	return ifmq
}
func (ifmq *InvalidFieldMessageQuery) First(ctx context.Context) (*InvalidFieldMessage, error) {
	nodes, err := ifmq.Limit(1).All(ctx)
	if err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nil, &NotFoundError{invalidfieldmessage.Label}
	}
	return nodes[0], nil
}
func (ifmq *InvalidFieldMessageQuery) FirstX(ctx context.Context) *InvalidFieldMessage {
	node, err := ifmq.First(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return node
}
func (ifmq *InvalidFieldMessageQuery) FirstID(ctx context.Context) (id int, err error) {
	var ids []int
	if ids, err = ifmq.Limit(1).IDs(ctx); err != nil {
		return
	}
	if len(ids) == 0 {
		err = &NotFoundError{invalidfieldmessage.Label}
		return
	}
	return ids[0], nil
}
func (ifmq *InvalidFieldMessageQuery) FirstIDX(ctx context.Context) int {
	id, err := ifmq.FirstID(ctx)
	if err != nil && !IsNotFound(err) {
		panic(err)
	}
	return id
}
func (ifmq *InvalidFieldMessageQuery) Only(ctx context.Context) (*InvalidFieldMessage, error) {
	nodes, err := ifmq.Limit(2).All(ctx)
	if err != nil {
		return nil, err
	}
	switch len(nodes) {
	case 1:
		return nodes[0], nil
	case 0:
		return nil, &NotFoundError{invalidfieldmessage.Label}
	default:
		return nil, &NotSingularError{invalidfieldmessage.Label}
	}
}
func (ifmq *InvalidFieldMessageQuery) OnlyX(ctx context.Context) *InvalidFieldMessage {
	node, err := ifmq.Only(ctx)
	if err != nil {
		panic(err)
	}
	return node
}
func (ifmq *InvalidFieldMessageQuery) OnlyID(ctx context.Context) (id int, err error) {
	var ids []int
	if ids, err = ifmq.Limit(2).IDs(ctx); err != nil {
		return
	}
	switch len(ids) {
	case 1:
		id = ids[0]
	case 0:
		err = &NotFoundError{invalidfieldmessage.Label}
	default:
		err = &NotSingularError{invalidfieldmessage.Label}
	}
	return
}
func (ifmq *InvalidFieldMessageQuery) OnlyIDX(ctx context.Context) int {
	id, err := ifmq.OnlyID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}
func (ifmq *InvalidFieldMessageQuery) All(ctx context.Context) ([]*InvalidFieldMessage, error) {
	if err := ifmq.prepareQuery(ctx); err != nil {
		return nil, err
	}
	return ifmq.sqlAll(ctx)
}
func (ifmq *InvalidFieldMessageQuery) AllX(ctx context.Context) []*InvalidFieldMessage {
	nodes, err := ifmq.All(ctx)
	if err != nil {
		panic(err)
	}
	return nodes
}
func (ifmq *InvalidFieldMessageQuery) IDs(ctx context.Context) ([]int, error) {
	var ids []int
	if err := ifmq.Select(invalidfieldmessage.FieldID).Scan(ctx, &ids); err != nil {
		return nil, err
	}
	return ids, nil
}
func (ifmq *InvalidFieldMessageQuery) IDsX(ctx context.Context) []int {
	ids, err := ifmq.IDs(ctx)
	if err != nil {
		panic(err)
	}
	return ids
}
func (ifmq *InvalidFieldMessageQuery) Count(ctx context.Context) (int, error) {
	if err := ifmq.prepareQuery(ctx); err != nil {
		return 0, err
	}
	return ifmq.sqlCount(ctx)
}
func (ifmq *InvalidFieldMessageQuery) CountX(ctx context.Context) int {
	count, err := ifmq.Count(ctx)
	if err != nil {
		panic(err)
	}
	return count
}
func (ifmq *InvalidFieldMessageQuery) Exist(ctx context.Context) (bool, error) {
	if err := ifmq.prepareQuery(ctx); err != nil {
		return false, err
	}
	return ifmq.sqlExist(ctx)
}
func (ifmq *InvalidFieldMessageQuery) ExistX(ctx context.Context) bool {
	exist, err := ifmq.Exist(ctx)
	if err != nil {
		panic(err)
	}
	return exist
}
func (ifmq *InvalidFieldMessageQuery) Clone() *InvalidFieldMessageQuery {
	if ifmq == nil {
		return nil
	}
	return &InvalidFieldMessageQuery{
		config:     ifmq.config,
		limit:      ifmq.limit,
		offset:     ifmq.offset,
		order:      append([]OrderFunc{}, ifmq.order...),
		predicates: append([]predicate.InvalidFieldMessage{}, ifmq.predicates...),
		sql:  ifmq.sql.Clone(),
		path: ifmq.path,
	}
}
func (ifmq *InvalidFieldMessageQuery) GroupBy(field string, fields ...string) *InvalidFieldMessageGroupBy {
	group := &InvalidFieldMessageGroupBy{config: ifmq.config}
	group.fields = append([]string{field}, fields...)
	group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
		if err := ifmq.prepareQuery(ctx); err != nil {
			return nil, err
		}
		return ifmq.sqlQuery(ctx), nil
	}
	return group
}
func (ifmq *InvalidFieldMessageQuery) Select(fields ...string) *InvalidFieldMessageSelect {
	ifmq.fields = append(ifmq.fields, fields...)
	return &InvalidFieldMessageSelect{InvalidFieldMessageQuery: ifmq}
}
func (ifmq *InvalidFieldMessageQuery) prepareQuery(ctx context.Context) error {
	for _, f := range ifmq.fields {
		if !invalidfieldmessage.ValidColumn(f) {
			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
		}
	}
	if ifmq.path != nil {
		prev, err := ifmq.path(ctx)
		if err != nil {
			return err
		}
		ifmq.sql = prev
	}
	return nil
}
func (ifmq *InvalidFieldMessageQuery) sqlAll(ctx context.Context) ([]*InvalidFieldMessage, error) {
	var (
		nodes = []*InvalidFieldMessage{}
		_spec = ifmq.querySpec()
	)
	_spec.ScanValues = func(columns []string) ([]interface{}, error) {
		node := &InvalidFieldMessage{config: ifmq.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, ifmq.driver, _spec); err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nodes, nil
	}
	return nodes, nil
}
func (ifmq *InvalidFieldMessageQuery) sqlCount(ctx context.Context) (int, error) {
	_spec := ifmq.querySpec()
	return sqlgraph.CountNodes(ctx, ifmq.driver, _spec)
}
func (ifmq *InvalidFieldMessageQuery) sqlExist(ctx context.Context) (bool, error) {
	n, err := ifmq.sqlCount(ctx)
	if err != nil {
		return false, fmt.Errorf("ent: check existence: %w", err)
	}
	return n > 0, nil
}
func (ifmq *InvalidFieldMessageQuery) querySpec() *sqlgraph.QuerySpec {
	_spec := &sqlgraph.QuerySpec{
		Node: &sqlgraph.NodeSpec{
			Table:   invalidfieldmessage.Table,
			Columns: invalidfieldmessage.Columns,
			ID: &sqlgraph.FieldSpec{
				Type:   field.TypeInt,
				Column: invalidfieldmessage.FieldID,
			},
		},
		From:   ifmq.sql,
		Unique: true,
	}
	if unique := ifmq.unique; unique != nil {
		_spec.Unique = *unique
	}
	if fields := ifmq.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, invalidfieldmessage.FieldID)
		for i := range fields {
			if fields[i] != invalidfieldmessage.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
			}
		}
	}
	if ps := ifmq.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if limit := ifmq.limit; limit != nil {
		_spec.Limit = *limit
	}
	if offset := ifmq.offset; offset != nil {
		_spec.Offset = *offset
	}
	if ps := ifmq.order; len(ps) > 0 {
		_spec.Order = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	return _spec
}
func (ifmq *InvalidFieldMessageQuery) sqlQuery(ctx context.Context) *sql.Selector {
	builder := sql.Dialect(ifmq.driver.Dialect())
	t1 := builder.Table(invalidfieldmessage.Table)
	columns := ifmq.fields
	if len(columns) == 0 {
		columns = invalidfieldmessage.Columns
	}
	selector := builder.Select(t1.Columns(columns...)...).From(t1)
	if ifmq.sql != nil {
		selector = ifmq.sql
		selector.Select(selector.Columns(columns...)...)
	}
	for _, p := range ifmq.predicates {
		p(selector)
	}
	for _, p := range ifmq.order {
		p(selector)
	}
	if offset := ifmq.offset; offset != nil {
		selector.Offset(*offset).Limit(math.MaxInt32)
	}
	if limit := ifmq.limit; limit != nil {
		selector.Limit(*limit)
	}
	return selector
}
type InvalidFieldMessageGroupBy struct {
	config
	fields []string
	fns    []AggregateFunc
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (ifmgb *InvalidFieldMessageGroupBy) Aggregate(fns ...AggregateFunc) *InvalidFieldMessageGroupBy {
	ifmgb.fns = append(ifmgb.fns, fns...)
	return ifmgb
}