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