// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/Wei-Shaw/sub2api/ent/userattributedefinition"
	"github.com/Wei-Shaw/sub2api/ent/userattributevalue"
)

// UserAttributeDefinitionCreate is the builder for creating a UserAttributeDefinition entity.
type UserAttributeDefinitionCreate struct {
	config
	mutation *UserAttributeDefinitionMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreatedAt sets the "created_at" field.
func (_c *UserAttributeDefinitionCreate) SetCreatedAt(v time.Time) *UserAttributeDefinitionCreate {
	_c.mutation.SetCreatedAt(v)
	return _c
}

// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *UserAttributeDefinitionCreate) SetNillableCreatedAt(v *time.Time) *UserAttributeDefinitionCreate {
	if v != nil {
		_c.SetCreatedAt(*v)
	}
	return _c
}

// SetUpdatedAt sets the "updated_at" field.
func (_c *UserAttributeDefinitionCreate) SetUpdatedAt(v time.Time) *UserAttributeDefinitionCreate {
	_c.mutation.SetUpdatedAt(v)
	return _c
}

// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *UserAttributeDefinitionCreate) SetNillableUpdatedAt(v *time.Time) *UserAttributeDefinitionCreate {
	if v != nil {
		_c.SetUpdatedAt(*v)
	}
	return _c
}

// SetDeletedAt sets the "deleted_at" field.
func (_c *UserAttributeDefinitionCreate) SetDeletedAt(v time.Time) *UserAttributeDefinitionCreate {
	_c.mutation.SetDeletedAt(v)
	return _c
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_c *UserAttributeDefinitionCreate) SetNillableDeletedAt(v *time.Time) *UserAttributeDefinitionCreate {
	if v != nil {
		_c.SetDeletedAt(*v)
	}
	return _c
}

// SetKey sets the "key" field.
func (_c *UserAttributeDefinitionCreate) SetKey(v string) *UserAttributeDefinitionCreate {
	_c.mutation.SetKey(v)
	return _c
}

// SetName sets the "name" field.
func (_c *UserAttributeDefinitionCreate) SetName(v string) *UserAttributeDefinitionCreate {
	_c.mutation.SetName(v)
	return _c
}

// SetDescription sets the "description" field.
func (_c *UserAttributeDefinitionCreate) SetDescription(v string) *UserAttributeDefinitionCreate {
	_c.mutation.SetDescription(v)
	return _c
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (_c *UserAttributeDefinitionCreate) SetNillableDescription(v *string) *UserAttributeDefinitionCreate {
	if v != nil {
		_c.SetDescription(*v)
	}
	return _c
}

// SetType sets the "type" field.
func (_c *UserAttributeDefinitionCreate) SetType(v string) *UserAttributeDefinitionCreate {
	_c.mutation.SetType(v)
	return _c
}

// SetOptions sets the "options" field.
func (_c *UserAttributeDefinitionCreate) SetOptions(v []map[string]interface{}) *UserAttributeDefinitionCreate {
	_c.mutation.SetOptions(v)
	return _c
}

// SetRequired sets the "required" field.
func (_c *UserAttributeDefinitionCreate) SetRequired(v bool) *UserAttributeDefinitionCreate {
	_c.mutation.SetRequired(v)
	return _c
}

// SetNillableRequired sets the "required" field if the given value is not nil.
func (_c *UserAttributeDefinitionCreate) SetNillableRequired(v *bool) *UserAttributeDefinitionCreate {
	if v != nil {
		_c.SetRequired(*v)
	}
	return _c
}

// SetValidation sets the "validation" field.
func (_c *UserAttributeDefinitionCreate) SetValidation(v map[string]interface{}) *UserAttributeDefinitionCreate {
	_c.mutation.SetValidation(v)
	return _c
}

// SetPlaceholder sets the "placeholder" field.
func (_c *UserAttributeDefinitionCreate) SetPlaceholder(v string) *UserAttributeDefinitionCreate {
	_c.mutation.SetPlaceholder(v)
	return _c
}

// SetNillablePlaceholder sets the "placeholder" field if the given value is not nil.
func (_c *UserAttributeDefinitionCreate) SetNillablePlaceholder(v *string) *UserAttributeDefinitionCreate {
	if v != nil {
		_c.SetPlaceholder(*v)
	}
	return _c
}

// SetDisplayOrder sets the "display_order" field.
func (_c *UserAttributeDefinitionCreate) SetDisplayOrder(v int) *UserAttributeDefinitionCreate {
	_c.mutation.SetDisplayOrder(v)
	return _c
}

// SetNillableDisplayOrder sets the "display_order" field if the given value is not nil.
func (_c *UserAttributeDefinitionCreate) SetNillableDisplayOrder(v *int) *UserAttributeDefinitionCreate {
	if v != nil {
		_c.SetDisplayOrder(*v)
	}
	return _c
}

// SetEnabled sets the "enabled" field.
func (_c *UserAttributeDefinitionCreate) SetEnabled(v bool) *UserAttributeDefinitionCreate {
	_c.mutation.SetEnabled(v)
	return _c
}

// SetNillableEnabled sets the "enabled" field if the given value is not nil.
func (_c *UserAttributeDefinitionCreate) SetNillableEnabled(v *bool) *UserAttributeDefinitionCreate {
	if v != nil {
		_c.SetEnabled(*v)
	}
	return _c
}

// AddValueIDs adds the "values" edge to the UserAttributeValue entity by IDs.
func (_c *UserAttributeDefinitionCreate) AddValueIDs(ids ...int64) *UserAttributeDefinitionCreate {
	_c.mutation.AddValueIDs(ids...)
	return _c
}

// AddValues adds the "values" edges to the UserAttributeValue entity.
func (_c *UserAttributeDefinitionCreate) AddValues(v ...*UserAttributeValue) *UserAttributeDefinitionCreate {
	ids := make([]int64, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _c.AddValueIDs(ids...)
}

// Mutation returns the UserAttributeDefinitionMutation object of the builder.
func (_c *UserAttributeDefinitionCreate) Mutation() *UserAttributeDefinitionMutation {
	return _c.mutation
}

// Save creates the UserAttributeDefinition in the database.
func (_c *UserAttributeDefinitionCreate) Save(ctx context.Context) (*UserAttributeDefinition, error) {
	if err := _c.defaults(); err != nil {
		return nil, err
	}
	return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}

// SaveX calls Save and panics if Save returns an error.
func (_c *UserAttributeDefinitionCreate) SaveX(ctx context.Context) *UserAttributeDefinition {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (_c *UserAttributeDefinitionCreate) Exec(ctx context.Context) error {
	_, err := _c.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_c *UserAttributeDefinitionCreate) ExecX(ctx context.Context) {
	if err := _c.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (_c *UserAttributeDefinitionCreate) defaults() error {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		if userattributedefinition.DefaultCreatedAt == nil {
			return fmt.Errorf("ent: uninitialized userattributedefinition.DefaultCreatedAt (forgotten import ent/runtime?)")
		}
		v := userattributedefinition.DefaultCreatedAt()
		_c.mutation.SetCreatedAt(v)
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		if userattributedefinition.DefaultUpdatedAt == nil {
			return fmt.Errorf("ent: uninitialized userattributedefinition.DefaultUpdatedAt (forgotten import ent/runtime?)")
		}
		v := userattributedefinition.DefaultUpdatedAt()
		_c.mutation.SetUpdatedAt(v)
	}
	if _, ok := _c.mutation.Description(); !ok {
		v := userattributedefinition.DefaultDescription
		_c.mutation.SetDescription(v)
	}
	if _, ok := _c.mutation.Options(); !ok {
		v := userattributedefinition.DefaultOptions
		_c.mutation.SetOptions(v)
	}
	if _, ok := _c.mutation.Required(); !ok {
		v := userattributedefinition.DefaultRequired
		_c.mutation.SetRequired(v)
	}
	if _, ok := _c.mutation.Validation(); !ok {
		v := userattributedefinition.DefaultValidation
		_c.mutation.SetValidation(v)
	}
	if _, ok := _c.mutation.Placeholder(); !ok {
		v := userattributedefinition.DefaultPlaceholder
		_c.mutation.SetPlaceholder(v)
	}
	if _, ok := _c.mutation.DisplayOrder(); !ok {
		v := userattributedefinition.DefaultDisplayOrder
		_c.mutation.SetDisplayOrder(v)
	}
	if _, ok := _c.mutation.Enabled(); !ok {
		v := userattributedefinition.DefaultEnabled
		_c.mutation.SetEnabled(v)
	}
	return nil
}

// check runs all checks and user-defined validators on the builder.
func (_c *UserAttributeDefinitionCreate) check() error {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserAttributeDefinition.created_at"`)}
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UserAttributeDefinition.updated_at"`)}
	}
	if _, ok := _c.mutation.Key(); !ok {
		return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "UserAttributeDefinition.key"`)}
	}
	if v, ok := _c.mutation.Key(); ok {
		if err := userattributedefinition.KeyValidator(v); err != nil {
			return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "UserAttributeDefinition.key": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Name(); !ok {
		return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "UserAttributeDefinition.name"`)}
	}
	if v, ok := _c.mutation.Name(); ok {
		if err := userattributedefinition.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "UserAttributeDefinition.name": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Description(); !ok {
		return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "UserAttributeDefinition.description"`)}
	}
	if _, ok := _c.mutation.GetType(); !ok {
		return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "UserAttributeDefinition.type"`)}
	}
	if v, ok := _c.mutation.GetType(); ok {
		if err := userattributedefinition.TypeValidator(v); err != nil {
			return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "UserAttributeDefinition.type": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Options(); !ok {
		return &ValidationError{Name: "options", err: errors.New(`ent: missing required field "UserAttributeDefinition.options"`)}
	}
	if _, ok := _c.mutation.Required(); !ok {
		return &ValidationError{Name: "required", err: errors.New(`ent: missing required field "UserAttributeDefinition.required"`)}
	}
	if _, ok := _c.mutation.Validation(); !ok {
		return &ValidationError{Name: "validation", err: errors.New(`ent: missing required field "UserAttributeDefinition.validation"`)}
	}
	if _, ok := _c.mutation.Placeholder(); !ok {
		return &ValidationError{Name: "placeholder", err: errors.New(`ent: missing required field "UserAttributeDefinition.placeholder"`)}
	}
	if v, ok := _c.mutation.Placeholder(); ok {
		if err := userattributedefinition.PlaceholderValidator(v); err != nil {
			return &ValidationError{Name: "placeholder", err: fmt.Errorf(`ent: validator failed for field "UserAttributeDefinition.placeholder": %w`, err)}
		}
	}
	if _, ok := _c.mutation.DisplayOrder(); !ok {
		return &ValidationError{Name: "display_order", err: errors.New(`ent: missing required field "UserAttributeDefinition.display_order"`)}
	}
	if _, ok := _c.mutation.Enabled(); !ok {
		return &ValidationError{Name: "enabled", err: errors.New(`ent: missing required field "UserAttributeDefinition.enabled"`)}
	}
	return nil
}

func (_c *UserAttributeDefinitionCreate) sqlSave(ctx context.Context) (*UserAttributeDefinition, error) {
	if err := _c.check(); err != nil {
		return nil, err
	}
	_node, _spec := _c.createSpec()
	if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	id := _spec.ID.Value.(int64)
	_node.ID = int64(id)
	_c.mutation.id = &_node.ID
	_c.mutation.done = true
	return _node, nil
}

func (_c *UserAttributeDefinitionCreate) createSpec() (*UserAttributeDefinition, *sqlgraph.CreateSpec) {
	var (
		_node = &UserAttributeDefinition{config: _c.config}
		_spec = sqlgraph.NewCreateSpec(userattributedefinition.Table, sqlgraph.NewFieldSpec(userattributedefinition.FieldID, field.TypeInt64))
	)
	_spec.OnConflict = _c.conflict
	if value, ok := _c.mutation.CreatedAt(); ok {
		_spec.SetField(userattributedefinition.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := _c.mutation.UpdatedAt(); ok {
		_spec.SetField(userattributedefinition.FieldUpdatedAt, field.TypeTime, value)
		_node.UpdatedAt = value
	}
	if value, ok := _c.mutation.DeletedAt(); ok {
		_spec.SetField(userattributedefinition.FieldDeletedAt, field.TypeTime, value)
		_node.DeletedAt = &value
	}
	if value, ok := _c.mutation.Key(); ok {
		_spec.SetField(userattributedefinition.FieldKey, field.TypeString, value)
		_node.Key = value
	}
	if value, ok := _c.mutation.Name(); ok {
		_spec.SetField(userattributedefinition.FieldName, field.TypeString, value)
		_node.Name = value
	}
	if value, ok := _c.mutation.Description(); ok {
		_spec.SetField(userattributedefinition.FieldDescription, field.TypeString, value)
		_node.Description = value
	}
	if value, ok := _c.mutation.GetType(); ok {
		_spec.SetField(userattributedefinition.FieldType, field.TypeString, value)
		_node.Type = value
	}
	if value, ok := _c.mutation.Options(); ok {
		_spec.SetField(userattributedefinition.FieldOptions, field.TypeJSON, value)
		_node.Options = value
	}
	if value, ok := _c.mutation.Required(); ok {
		_spec.SetField(userattributedefinition.FieldRequired, field.TypeBool, value)
		_node.Required = value
	}
	if value, ok := _c.mutation.Validation(); ok {
		_spec.SetField(userattributedefinition.FieldValidation, field.TypeJSON, value)
		_node.Validation = value
	}
	if value, ok := _c.mutation.Placeholder(); ok {
		_spec.SetField(userattributedefinition.FieldPlaceholder, field.TypeString, value)
		_node.Placeholder = value
	}
	if value, ok := _c.mutation.DisplayOrder(); ok {
		_spec.SetField(userattributedefinition.FieldDisplayOrder, field.TypeInt, value)
		_node.DisplayOrder = value
	}
	if value, ok := _c.mutation.Enabled(); ok {
		_spec.SetField(userattributedefinition.FieldEnabled, field.TypeBool, value)
		_node.Enabled = value
	}
	if nodes := _c.mutation.ValuesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   userattributedefinition.ValuesTable,
			Columns: []string{userattributedefinition.ValuesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(userattributevalue.FieldID, field.TypeInt64),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.UserAttributeDefinition.Create().
//		SetCreatedAt(v).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.UserAttributeDefinitionUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (_c *UserAttributeDefinitionCreate) OnConflict(opts ...sql.ConflictOption) *UserAttributeDefinitionUpsertOne {
	_c.conflict = opts
	return &UserAttributeDefinitionUpsertOne{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.UserAttributeDefinition.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *UserAttributeDefinitionCreate) OnConflictColumns(columns ...string) *UserAttributeDefinitionUpsertOne {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &UserAttributeDefinitionUpsertOne{
		create: _c,
	}
}

type (
	// UserAttributeDefinitionUpsertOne is the builder for "upsert"-ing
	//  one UserAttributeDefinition node.
	UserAttributeDefinitionUpsertOne struct {
		create *UserAttributeDefinitionCreate
	}

	// UserAttributeDefinitionUpsert is the "OnConflict" setter.
	UserAttributeDefinitionUpsert struct {
		*sql.UpdateSet
	}
)

// SetUpdatedAt sets the "updated_at" field.
func (u *UserAttributeDefinitionUpsert) SetUpdatedAt(v time.Time) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldUpdatedAt, v)
	return u
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateUpdatedAt() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldUpdatedAt)
	return u
}

// SetDeletedAt sets the "deleted_at" field.
func (u *UserAttributeDefinitionUpsert) SetDeletedAt(v time.Time) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldDeletedAt, v)
	return u
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateDeletedAt() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldDeletedAt)
	return u
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *UserAttributeDefinitionUpsert) ClearDeletedAt() *UserAttributeDefinitionUpsert {
	u.SetNull(userattributedefinition.FieldDeletedAt)
	return u
}

// SetKey sets the "key" field.
func (u *UserAttributeDefinitionUpsert) SetKey(v string) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldKey, v)
	return u
}

// UpdateKey sets the "key" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateKey() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldKey)
	return u
}

// SetName sets the "name" field.
func (u *UserAttributeDefinitionUpsert) SetName(v string) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldName, v)
	return u
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateName() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldName)
	return u
}

// SetDescription sets the "description" field.
func (u *UserAttributeDefinitionUpsert) SetDescription(v string) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldDescription, v)
	return u
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateDescription() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldDescription)
	return u
}

// SetType sets the "type" field.
func (u *UserAttributeDefinitionUpsert) SetType(v string) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldType, v)
	return u
}

// UpdateType sets the "type" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateType() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldType)
	return u
}

// SetOptions sets the "options" field.
func (u *UserAttributeDefinitionUpsert) SetOptions(v []map[string]interface{}) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldOptions, v)
	return u
}

// UpdateOptions sets the "options" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateOptions() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldOptions)
	return u
}

// SetRequired sets the "required" field.
func (u *UserAttributeDefinitionUpsert) SetRequired(v bool) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldRequired, v)
	return u
}

// UpdateRequired sets the "required" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateRequired() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldRequired)
	return u
}

// SetValidation sets the "validation" field.
func (u *UserAttributeDefinitionUpsert) SetValidation(v map[string]interface{}) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldValidation, v)
	return u
}

// UpdateValidation sets the "validation" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateValidation() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldValidation)
	return u
}

// SetPlaceholder sets the "placeholder" field.
func (u *UserAttributeDefinitionUpsert) SetPlaceholder(v string) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldPlaceholder, v)
	return u
}

// UpdatePlaceholder sets the "placeholder" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdatePlaceholder() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldPlaceholder)
	return u
}

// SetDisplayOrder sets the "display_order" field.
func (u *UserAttributeDefinitionUpsert) SetDisplayOrder(v int) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldDisplayOrder, v)
	return u
}

// UpdateDisplayOrder sets the "display_order" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateDisplayOrder() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldDisplayOrder)
	return u
}

// AddDisplayOrder adds v to the "display_order" field.
func (u *UserAttributeDefinitionUpsert) AddDisplayOrder(v int) *UserAttributeDefinitionUpsert {
	u.Add(userattributedefinition.FieldDisplayOrder, v)
	return u
}

// SetEnabled sets the "enabled" field.
func (u *UserAttributeDefinitionUpsert) SetEnabled(v bool) *UserAttributeDefinitionUpsert {
	u.Set(userattributedefinition.FieldEnabled, v)
	return u
}

// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsert) UpdateEnabled() *UserAttributeDefinitionUpsert {
	u.SetExcluded(userattributedefinition.FieldEnabled)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
//	client.UserAttributeDefinition.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//		).
//		Exec(ctx)
func (u *UserAttributeDefinitionUpsertOne) UpdateNewValues() *UserAttributeDefinitionUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		if _, exists := u.create.mutation.CreatedAt(); exists {
			s.SetIgnore(userattributedefinition.FieldCreatedAt)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.UserAttributeDefinition.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *UserAttributeDefinitionUpsertOne) Ignore() *UserAttributeDefinitionUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *UserAttributeDefinitionUpsertOne) DoNothing() *UserAttributeDefinitionUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the UserAttributeDefinitionCreate.OnConflict
// documentation for more info.
func (u *UserAttributeDefinitionUpsertOne) Update(set func(*UserAttributeDefinitionUpsert)) *UserAttributeDefinitionUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&UserAttributeDefinitionUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdatedAt sets the "updated_at" field.
func (u *UserAttributeDefinitionUpsertOne) SetUpdatedAt(v time.Time) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateUpdatedAt() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetDeletedAt sets the "deleted_at" field.
func (u *UserAttributeDefinitionUpsertOne) SetDeletedAt(v time.Time) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetDeletedAt(v)
	})
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateDeletedAt() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateDeletedAt()
	})
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *UserAttributeDefinitionUpsertOne) ClearDeletedAt() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.ClearDeletedAt()
	})
}

// SetKey sets the "key" field.
func (u *UserAttributeDefinitionUpsertOne) SetKey(v string) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetKey(v)
	})
}

// UpdateKey sets the "key" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateKey() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateKey()
	})
}

// SetName sets the "name" field.
func (u *UserAttributeDefinitionUpsertOne) SetName(v string) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetName(v)
	})
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateName() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateName()
	})
}

// SetDescription sets the "description" field.
func (u *UserAttributeDefinitionUpsertOne) SetDescription(v string) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetDescription(v)
	})
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateDescription() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateDescription()
	})
}

// SetType sets the "type" field.
func (u *UserAttributeDefinitionUpsertOne) SetType(v string) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetType(v)
	})
}

// UpdateType sets the "type" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateType() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateType()
	})
}

// SetOptions sets the "options" field.
func (u *UserAttributeDefinitionUpsertOne) SetOptions(v []map[string]interface{}) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetOptions(v)
	})
}

// UpdateOptions sets the "options" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateOptions() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateOptions()
	})
}

// SetRequired sets the "required" field.
func (u *UserAttributeDefinitionUpsertOne) SetRequired(v bool) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetRequired(v)
	})
}

// UpdateRequired sets the "required" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateRequired() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateRequired()
	})
}

// SetValidation sets the "validation" field.
func (u *UserAttributeDefinitionUpsertOne) SetValidation(v map[string]interface{}) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetValidation(v)
	})
}

// UpdateValidation sets the "validation" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateValidation() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateValidation()
	})
}

// SetPlaceholder sets the "placeholder" field.
func (u *UserAttributeDefinitionUpsertOne) SetPlaceholder(v string) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetPlaceholder(v)
	})
}

// UpdatePlaceholder sets the "placeholder" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdatePlaceholder() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdatePlaceholder()
	})
}

// SetDisplayOrder sets the "display_order" field.
func (u *UserAttributeDefinitionUpsertOne) SetDisplayOrder(v int) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetDisplayOrder(v)
	})
}

// AddDisplayOrder adds v to the "display_order" field.
func (u *UserAttributeDefinitionUpsertOne) AddDisplayOrder(v int) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.AddDisplayOrder(v)
	})
}

// UpdateDisplayOrder sets the "display_order" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateDisplayOrder() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateDisplayOrder()
	})
}

// SetEnabled sets the "enabled" field.
func (u *UserAttributeDefinitionUpsertOne) SetEnabled(v bool) *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetEnabled(v)
	})
}

// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertOne) UpdateEnabled() *UserAttributeDefinitionUpsertOne {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateEnabled()
	})
}

// Exec executes the query.
func (u *UserAttributeDefinitionUpsertOne) Exec(ctx context.Context) error {
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for UserAttributeDefinitionCreate.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *UserAttributeDefinitionUpsertOne) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}

// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *UserAttributeDefinitionUpsertOne) ID(ctx context.Context) (id int64, err error) {
	node, err := u.create.Save(ctx)
	if err != nil {
		return id, err
	}
	return node.ID, nil
}

// IDX is like ID, but panics if an error occurs.
func (u *UserAttributeDefinitionUpsertOne) IDX(ctx context.Context) int64 {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// UserAttributeDefinitionCreateBulk is the builder for creating many UserAttributeDefinition entities in bulk.
type UserAttributeDefinitionCreateBulk struct {
	config
	err      error
	builders []*UserAttributeDefinitionCreate
	conflict []sql.ConflictOption
}

// Save creates the UserAttributeDefinition entities in the database.
func (_c *UserAttributeDefinitionCreateBulk) Save(ctx context.Context) ([]*UserAttributeDefinition, error) {
	if _c.err != nil {
		return nil, _c.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
	nodes := make([]*UserAttributeDefinition, len(_c.builders))
	mutators := make([]Mutator, len(_c.builders))
	for i := range _c.builders {
		func(i int, root context.Context) {
			builder := _c.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*UserAttributeDefinitionMutation)
				if !ok {
					return nil, fmt.Errorf("unexpected mutation type %T", m)
				}
				if err := builder.check(); err != nil {
					return nil, err
				}
				builder.mutation = mutation
				var err error
				nodes[i], specs[i] = builder.createSpec()
				if i < len(mutators)-1 {
					_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = _c.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
						if sqlgraph.IsConstraintError(err) {
							err = &ConstraintError{msg: err.Error(), wrap: err}
						}
					}
				}
				if err != nil {
					return nil, err
				}
				mutation.id = &nodes[i].ID
				if specs[i].ID.Value != nil {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = int64(id)
				}
				mutation.done = true
				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, _c.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

// SaveX is like Save, but panics if an error occurs.
func (_c *UserAttributeDefinitionCreateBulk) SaveX(ctx context.Context) []*UserAttributeDefinition {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (_c *UserAttributeDefinitionCreateBulk) Exec(ctx context.Context) error {
	_, err := _c.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_c *UserAttributeDefinitionCreateBulk) ExecX(ctx context.Context) {
	if err := _c.Exec(ctx); err != nil {
		panic(err)
	}
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.UserAttributeDefinition.CreateBulk(builders...).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.UserAttributeDefinitionUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (_c *UserAttributeDefinitionCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserAttributeDefinitionUpsertBulk {
	_c.conflict = opts
	return &UserAttributeDefinitionUpsertBulk{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.UserAttributeDefinition.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *UserAttributeDefinitionCreateBulk) OnConflictColumns(columns ...string) *UserAttributeDefinitionUpsertBulk {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &UserAttributeDefinitionUpsertBulk{
		create: _c,
	}
}

// UserAttributeDefinitionUpsertBulk is the builder for "upsert"-ing
// a bulk of UserAttributeDefinition nodes.
type UserAttributeDefinitionUpsertBulk struct {
	create *UserAttributeDefinitionCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.UserAttributeDefinition.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//		).
//		Exec(ctx)
func (u *UserAttributeDefinitionUpsertBulk) UpdateNewValues() *UserAttributeDefinitionUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		for _, b := range u.create.builders {
			if _, exists := b.mutation.CreatedAt(); exists {
				s.SetIgnore(userattributedefinition.FieldCreatedAt)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.UserAttributeDefinition.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *UserAttributeDefinitionUpsertBulk) Ignore() *UserAttributeDefinitionUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *UserAttributeDefinitionUpsertBulk) DoNothing() *UserAttributeDefinitionUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the UserAttributeDefinitionCreateBulk.OnConflict
// documentation for more info.
func (u *UserAttributeDefinitionUpsertBulk) Update(set func(*UserAttributeDefinitionUpsert)) *UserAttributeDefinitionUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&UserAttributeDefinitionUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdatedAt sets the "updated_at" field.
func (u *UserAttributeDefinitionUpsertBulk) SetUpdatedAt(v time.Time) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateUpdatedAt() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetDeletedAt sets the "deleted_at" field.
func (u *UserAttributeDefinitionUpsertBulk) SetDeletedAt(v time.Time) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetDeletedAt(v)
	})
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateDeletedAt() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateDeletedAt()
	})
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *UserAttributeDefinitionUpsertBulk) ClearDeletedAt() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.ClearDeletedAt()
	})
}

// SetKey sets the "key" field.
func (u *UserAttributeDefinitionUpsertBulk) SetKey(v string) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetKey(v)
	})
}

// UpdateKey sets the "key" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateKey() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateKey()
	})
}

// SetName sets the "name" field.
func (u *UserAttributeDefinitionUpsertBulk) SetName(v string) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetName(v)
	})
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateName() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateName()
	})
}

// SetDescription sets the "description" field.
func (u *UserAttributeDefinitionUpsertBulk) SetDescription(v string) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetDescription(v)
	})
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateDescription() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateDescription()
	})
}

// SetType sets the "type" field.
func (u *UserAttributeDefinitionUpsertBulk) SetType(v string) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetType(v)
	})
}

// UpdateType sets the "type" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateType() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateType()
	})
}

// SetOptions sets the "options" field.
func (u *UserAttributeDefinitionUpsertBulk) SetOptions(v []map[string]interface{}) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetOptions(v)
	})
}

// UpdateOptions sets the "options" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateOptions() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateOptions()
	})
}

// SetRequired sets the "required" field.
func (u *UserAttributeDefinitionUpsertBulk) SetRequired(v bool) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetRequired(v)
	})
}

// UpdateRequired sets the "required" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateRequired() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateRequired()
	})
}

// SetValidation sets the "validation" field.
func (u *UserAttributeDefinitionUpsertBulk) SetValidation(v map[string]interface{}) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetValidation(v)
	})
}

// UpdateValidation sets the "validation" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateValidation() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateValidation()
	})
}

// SetPlaceholder sets the "placeholder" field.
func (u *UserAttributeDefinitionUpsertBulk) SetPlaceholder(v string) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetPlaceholder(v)
	})
}

// UpdatePlaceholder sets the "placeholder" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdatePlaceholder() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdatePlaceholder()
	})
}

// SetDisplayOrder sets the "display_order" field.
func (u *UserAttributeDefinitionUpsertBulk) SetDisplayOrder(v int) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetDisplayOrder(v)
	})
}

// AddDisplayOrder adds v to the "display_order" field.
func (u *UserAttributeDefinitionUpsertBulk) AddDisplayOrder(v int) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.AddDisplayOrder(v)
	})
}

// UpdateDisplayOrder sets the "display_order" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateDisplayOrder() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateDisplayOrder()
	})
}

// SetEnabled sets the "enabled" field.
func (u *UserAttributeDefinitionUpsertBulk) SetEnabled(v bool) *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.SetEnabled(v)
	})
}

// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func (u *UserAttributeDefinitionUpsertBulk) UpdateEnabled() *UserAttributeDefinitionUpsertBulk {
	return u.Update(func(s *UserAttributeDefinitionUpsert) {
		s.UpdateEnabled()
	})
}

// Exec executes the query.
func (u *UserAttributeDefinitionUpsertBulk) Exec(ctx context.Context) error {
	if u.create.err != nil {
		return u.create.err
	}
	for i, b := range u.create.builders {
		if len(b.conflict) != 0 {
			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UserAttributeDefinitionCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for UserAttributeDefinitionCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *UserAttributeDefinitionUpsertBulk) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}
