func (wnfcb *WithNilFieldsCreateBulk) ExecX(ctx context.Context) {
	if err := wnfcb.Exec(ctx); err != nil {
		panic(err)
	}
}
ExecX is like Exec, but panics if an error occurs.
package ent
import (
	"context"
	"fmt"
	"entgo.io/contrib/schemast/internal/mutatetest/ent/withnilfields"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type WithNilFieldsCreate struct {
	config
	mutation *WithNilFieldsMutation
	hooks    []Hook
}
func (wnfc *WithNilFieldsCreate) Mutation() *WithNilFieldsMutation {
	return wnfc.mutation
}
func (wnfc *WithNilFieldsCreate) Save(ctx context.Context) (*WithNilFields, error) {
	var (
		err  error
		node *WithNilFields
	)
	if len(wnfc.hooks) == 0 {
		if err = wnfc.check(); err != nil {
			return nil, err
		}
		node, err = wnfc.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*WithNilFieldsMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			if err = wnfc.check(); err != nil {
				return nil, err
			}
			wnfc.mutation = mutation
			if node, err = wnfc.sqlSave(ctx); err != nil {
				return nil, err
			}
			mutation.id = &node.ID
			mutation.done = true
			return node, err
		})
		for i := len(wnfc.hooks) - 1; i >= 0; i-- {
			if wnfc.hooks[i] == nil {
				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
			}
			mut = wnfc.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, wnfc.mutation); err != nil {
			return nil, err
		}
	}
	return node, err
}
func (wnfc *WithNilFieldsCreate) SaveX(ctx context.Context) *WithNilFields {
	v, err := wnfc.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}
func (wnfc *WithNilFieldsCreate) Exec(ctx context.Context) error {
	_, err := wnfc.Save(ctx)
	return err
}
func (wnfc *WithNilFieldsCreate) ExecX(ctx context.Context) {
	if err := wnfc.Exec(ctx); err != nil {
		panic(err)
	}
}
func (wnfc *WithNilFieldsCreate) check() error {
	return nil
}
func (wnfc *WithNilFieldsCreate) sqlSave(ctx context.Context) (*WithNilFields, error) {
	_node, _spec := wnfc.createSpec()
	if err := sqlgraph.CreateNode(ctx, wnfc.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{err.Error(), err}
		}
		return nil, err
	}
	id := _spec.ID.Value.(int64)
	_node.ID = int(id)
	return _node, nil
}
func (wnfc *WithNilFieldsCreate) createSpec() (*WithNilFields, *sqlgraph.CreateSpec) {
	var (
		_node = &WithNilFields{config: wnfc.config}
		_spec = &sqlgraph.CreateSpec{
			Table: withnilfields.Table,
			ID: &sqlgraph.FieldSpec{
				Type:   field.TypeInt,
				Column: withnilfields.FieldID,
			},
		}
	)
	return _node, _spec
}
type WithNilFieldsCreateBulk struct {
	config
	builders []*WithNilFieldsCreate
}
func (wnfcb *WithNilFieldsCreateBulk) Save(ctx context.Context) ([]*WithNilFields, error) {
	specs := make([]*sqlgraph.CreateSpec, len(wnfcb.builders))
	nodes := make([]*WithNilFields, len(wnfcb.builders))
	mutators := make([]Mutator, len(wnfcb.builders))
	for i := range wnfcb.builders {
		func(i int, root context.Context) {
			builder := wnfcb.builders[i]
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*WithNilFieldsMutation)
				if !ok {
					return nil, fmt.Errorf("unexpected mutation type %T", m)
				}
				if err := builder.check(); err != nil {
					return nil, err
				}
				builder.mutation = mutation
				nodes[i], specs[i] = builder.createSpec()
				var err error
				if i < len(mutators)-1 {
					_, err = mutators[i+1].Mutate(root, wnfcb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					if err = sqlgraph.BatchCreate(ctx, wnfcb.driver, spec); err != nil {
						if sqlgraph.IsConstraintError(err) {
							err = &ConstraintError{err.Error(), err}
						}
					}
				}
				if err != nil {
					return nil, err
				}
				mutation.id = &nodes[i].ID
				mutation.done = true
				if specs[i].ID.Value != nil {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = int(id)
				}
				return nodes[i], nil
			})
			for i := len(builder.hooks) - 1; i >= 0; i-- {
				mut = builder.hooks[i](mut)
			}
			mutators[i] = mut
		}(i, ctx)
	}
	if len(mutators) > 0 {
		if _, err := mutators[0].Mutate(ctx, wnfcb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}
func (wnfcb *WithNilFieldsCreateBulk) SaveX(ctx context.Context) []*WithNilFields {
	v, err := wnfcb.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}
func (wnfcb *WithNilFieldsCreateBulk) Exec(ctx context.Context) error {
	_, err := wnfcb.Save(ctx)
	return err
}