func withWithModifiedFieldID(id int) withmodifiedfieldOption {
	return func(m *WithModifiedFieldMutation) {
		var (
			err   error
			once  sync.Once
			value *WithModifiedField
		)
		m.oldValue = func(ctx context.Context) (*WithModifiedField, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().WithModifiedField.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
withWithModifiedFieldID sets the ID field of the mutation.
package ent
import (
	"context"
	"fmt"
	"sync"
	"entgo.io/contrib/schemast/internal/mutatetest/ent/predicate"
	"entgo.io/contrib/schemast/internal/mutatetest/ent/withfields"
	"entgo.io/contrib/schemast/internal/mutatetest/ent/withmodifiedfield"
	"entgo.io/ent"
)
const (
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne
	TypeUser              = "User"
	TypeWithFields        = "WithFields"
	TypeWithModifiedField = "WithModifiedField"
	TypeWithNilFields     = "WithNilFields"
	TypeWithoutFields     = "WithoutFields"
)
type UserMutation struct {
	config
	op            Op
	typ           string
	id            *int
	clearedFields map[string]struct{}
	done          bool
	oldValue      func(context.Context) (*User, error)
	predicates    []predicate.User
}
var _ ent.Mutation = (*UserMutation)(nil)
type userOption func(*UserMutation)
func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
	m := &UserMutation{
		config:        c,
		op:            op,
		typ:           TypeUser,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}
func withUserID(id int) userOption {
	return func(m *UserMutation) {
		var (
			err   error
			once  sync.Once
			value *User
		)
		m.oldValue = func(ctx context.Context) (*User, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().User.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
func withUser(node *User) userOption {
	return func(m *UserMutation) {
		m.oldValue = func(context.Context) (*User, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}
func (m UserMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}
func (m UserMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}
func (m *UserMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *UserMutation) Where(ps ...predicate.User) {
	m.predicates = append(m.predicates, ps...)
}
func (m *UserMutation) Op() Op {
	return m.op
}
func (m *UserMutation) Type() string {
	return m.typ
}
func (m *UserMutation) Fields() []string {
	fields := make([]string, 0, 0)
	return fields
}
func (m *UserMutation) Field(name string) (ent.Value, bool) {
	return nil, false
}
func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	return nil, fmt.Errorf("unknown User field %s", name)
}
func (m *UserMutation) SetField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown User field %s", name)
}
func (m *UserMutation) AddedFields() []string {
	return nil
}
func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}
func (m *UserMutation) AddField(name string, value ent.Value) error {
	return fmt.Errorf("unknown User numeric field %s", name)
}
func (m *UserMutation) ClearedFields() []string {
	return nil
}
func (m *UserMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}
func (m *UserMutation) ClearField(name string) error {
	return fmt.Errorf("unknown User nullable field %s", name)
}
func (m *UserMutation) ResetField(name string) error {
	return fmt.Errorf("unknown User field %s", name)
}
func (m *UserMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *UserMutation) AddedIDs(name string) []ent.Value {
	return nil
}
func (m *UserMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *UserMutation) RemovedIDs(name string) []ent.Value {
	return nil
}
func (m *UserMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *UserMutation) EdgeCleared(name string) bool {
	return false
}
func (m *UserMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown User unique edge %s", name)
}
func (m *UserMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown User edge %s", name)
}
type WithFieldsMutation struct {
	config
	op            Op
	typ           string
	id            *int
	existing      *string
	clearedFields map[string]struct{}
	done          bool
	oldValue      func(context.Context) (*WithFields, error)
	predicates    []predicate.WithFields
}
var _ ent.Mutation = (*WithFieldsMutation)(nil)
type withfieldsOption func(*WithFieldsMutation)
func newWithFieldsMutation(c config, op Op, opts ...withfieldsOption) *WithFieldsMutation {
	m := &WithFieldsMutation{
		config:        c,
		op:            op,
		typ:           TypeWithFields,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}
func withWithFieldsID(id int) withfieldsOption {
	return func(m *WithFieldsMutation) {
		var (
			err   error
			once  sync.Once
			value *WithFields
		)
		m.oldValue = func(ctx context.Context) (*WithFields, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().WithFields.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
func withWithFields(node *WithFields) withfieldsOption {
	return func(m *WithFieldsMutation) {
		m.oldValue = func(context.Context) (*WithFields, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}
func (m WithFieldsMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}
func (m WithFieldsMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}
func (m *WithFieldsMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *WithFieldsMutation) SetExisting(s string) {
	m.existing = &s
}
func (m *WithFieldsMutation) Existing() (r string, exists bool) {
	v := m.existing
	if v == nil {
		return
	}
	return *v, true
}
func (m *WithFieldsMutation) OldExisting(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldExisting is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldExisting requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldExisting: %w", err)
	}
	return oldValue.Existing, nil
}
func (m *WithFieldsMutation) ResetExisting() {
	m.existing = nil
}
func (m *WithFieldsMutation) Where(ps ...predicate.WithFields) {
	m.predicates = append(m.predicates, ps...)
}
func (m *WithFieldsMutation) Op() Op {
	return m.op
}
func (m *WithFieldsMutation) Type() string {
	return m.typ
}
func (m *WithFieldsMutation) Fields() []string {
	fields := make([]string, 0, 1)
	if m.existing != nil {
		fields = append(fields, withfields.FieldExisting)
	}
	return fields
}
func (m *WithFieldsMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case withfields.FieldExisting:
		return m.Existing()
	}
	return nil, false
}
func (m *WithFieldsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case withfields.FieldExisting:
		return m.OldExisting(ctx)
	}
	return nil, fmt.Errorf("unknown WithFields field %s", name)
}
func (m *WithFieldsMutation) SetField(name string, value ent.Value) error {
	switch name {
	case withfields.FieldExisting:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetExisting(v)
		return nil
	}
	return fmt.Errorf("unknown WithFields field %s", name)
}
func (m *WithFieldsMutation) AddedFields() []string {
	return nil
}
func (m *WithFieldsMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}
func (m *WithFieldsMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown WithFields numeric field %s", name)
}
func (m *WithFieldsMutation) ClearedFields() []string {
	return nil
}
func (m *WithFieldsMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}
func (m *WithFieldsMutation) ClearField(name string) error {
	return fmt.Errorf("unknown WithFields nullable field %s", name)
}
func (m *WithFieldsMutation) ResetField(name string) error {
	switch name {
	case withfields.FieldExisting:
		m.ResetExisting()
		return nil
	}
	return fmt.Errorf("unknown WithFields field %s", name)
}
func (m *WithFieldsMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *WithFieldsMutation) AddedIDs(name string) []ent.Value {
	return nil
}
func (m *WithFieldsMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *WithFieldsMutation) RemovedIDs(name string) []ent.Value {
	return nil
}
func (m *WithFieldsMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}
func (m *WithFieldsMutation) EdgeCleared(name string) bool {
	return false
}
func (m *WithFieldsMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown WithFields unique edge %s", name)
}
func (m *WithFieldsMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown WithFields edge %s", name)
}
type WithModifiedFieldMutation struct {
	config
	op            Op
	typ           string
	id            *int
	name          *string
	clearedFields map[string]struct{}
	owner         *int
	clearedowner  bool
	done          bool
	oldValue      func(context.Context) (*WithModifiedField, error)
	predicates    []predicate.WithModifiedField
}
var _ ent.Mutation = (*WithModifiedFieldMutation)(nil)
type withmodifiedfieldOption func(*WithModifiedFieldMutation)
func newWithModifiedFieldMutation(c config, op Op, opts ...withmodifiedfieldOption) *WithModifiedFieldMutation {
	m := &WithModifiedFieldMutation{
		config:        c,
		op:            op,
		typ:           TypeWithModifiedField,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}