// Code generated by entc, 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/pingcap/test-infra/common/model"
	"github.com/pingcap/test-infra/services/tcms/service/store/v2/ent/casetriage"
)

// CaseTriageCreate is the builder for creating a CaseTriage entity.
type CaseTriageCreate struct {
	config
	mutation *CaseTriageMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreatedAt sets the "createdAt" field.
func (ctc *CaseTriageCreate) SetCreatedAt(t time.Time) *CaseTriageCreate {
	ctc.mutation.SetCreatedAt(t)
	return ctc
}

// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
func (ctc *CaseTriageCreate) SetNillableCreatedAt(t *time.Time) *CaseTriageCreate {
	if t != nil {
		ctc.SetCreatedAt(*t)
	}
	return ctc
}

// SetUpdatedAt sets the "updatedAt" field.
func (ctc *CaseTriageCreate) SetUpdatedAt(t time.Time) *CaseTriageCreate {
	ctc.mutation.SetUpdatedAt(t)
	return ctc
}

// SetNillableUpdatedAt sets the "updatedAt" field if the given value is not nil.
func (ctc *CaseTriageCreate) SetNillableUpdatedAt(t *time.Time) *CaseTriageCreate {
	if t != nil {
		ctc.SetUpdatedAt(*t)
	}
	return ctc
}

// SetPlanExecutionID sets the "planExecutionID" field.
func (ctc *CaseTriageCreate) SetPlanExecutionID(m model.ID) *CaseTriageCreate {
	ctc.mutation.SetPlanExecutionID(m)
	return ctc
}

// SetPlanID sets the "planID" field.
func (ctc *CaseTriageCreate) SetPlanID(m model.ID) *CaseTriageCreate {
	ctc.mutation.SetPlanID(m)
	return ctc
}

// SetCaseExecutionID sets the "caseExecutionID" field.
func (ctc *CaseTriageCreate) SetCaseExecutionID(m model.ID) *CaseTriageCreate {
	ctc.mutation.SetCaseExecutionID(m)
	return ctc
}

// SetCaseID sets the "caseID" field.
func (ctc *CaseTriageCreate) SetCaseID(m model.ID) *CaseTriageCreate {
	ctc.mutation.SetCaseID(m)
	return ctc
}

// SetReason sets the "reason" field.
func (ctc *CaseTriageCreate) SetReason(mefr model.CaseExecFailReason) *CaseTriageCreate {
	ctc.mutation.SetReason(mefr)
	return ctc
}

// SetNillableReason sets the "reason" field if the given value is not nil.
func (ctc *CaseTriageCreate) SetNillableReason(mefr *model.CaseExecFailReason) *CaseTriageCreate {
	if mefr != nil {
		ctc.SetReason(*mefr)
	}
	return ctc
}

// SetSolution sets the "solution" field.
func (ctc *CaseTriageCreate) SetSolution(mfs model.ExecFailSolution) *CaseTriageCreate {
	ctc.mutation.SetSolution(mfs)
	return ctc
}

// SetNillableSolution sets the "solution" field if the given value is not nil.
func (ctc *CaseTriageCreate) SetNillableSolution(mfs *model.ExecFailSolution) *CaseTriageCreate {
	if mfs != nil {
		ctc.SetSolution(*mfs)
	}
	return ctc
}

// SetIssueLink sets the "issueLink" field.
func (ctc *CaseTriageCreate) SetIssueLink(s string) *CaseTriageCreate {
	ctc.mutation.SetIssueLink(s)
	return ctc
}

// SetNillableIssueLink sets the "issueLink" field if the given value is not nil.
func (ctc *CaseTriageCreate) SetNillableIssueLink(s *string) *CaseTriageCreate {
	if s != nil {
		ctc.SetIssueLink(*s)
	}
	return ctc
}

// SetNote sets the "note" field.
func (ctc *CaseTriageCreate) SetNote(s string) *CaseTriageCreate {
	ctc.mutation.SetNote(s)
	return ctc
}

// SetNillableNote sets the "note" field if the given value is not nil.
func (ctc *CaseTriageCreate) SetNillableNote(s *string) *CaseTriageCreate {
	if s != nil {
		ctc.SetNote(*s)
	}
	return ctc
}

// SetForkedFrom sets the "forkedFrom" field.
func (ctc *CaseTriageCreate) SetForkedFrom(m model.ID) *CaseTriageCreate {
	ctc.mutation.SetForkedFrom(m)
	return ctc
}

// SetNillableForkedFrom sets the "forkedFrom" field if the given value is not nil.
func (ctc *CaseTriageCreate) SetNillableForkedFrom(m *model.ID) *CaseTriageCreate {
	if m != nil {
		ctc.SetForkedFrom(*m)
	}
	return ctc
}

// SetID sets the "id" field.
func (ctc *CaseTriageCreate) SetID(m model.ID) *CaseTriageCreate {
	ctc.mutation.SetID(m)
	return ctc
}

// Mutation returns the CaseTriageMutation object of the builder.
func (ctc *CaseTriageCreate) Mutation() *CaseTriageMutation {
	return ctc.mutation
}

// Save creates the CaseTriage in the database.
func (ctc *CaseTriageCreate) Save(ctx context.Context) (*CaseTriage, error) {
	var (
		err  error
		node *CaseTriage
	)
	ctc.defaults()
	if len(ctc.hooks) == 0 {
		if err = ctc.check(); err != nil {
			return nil, err
		}
		node, err = ctc.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*CaseTriageMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			if err = ctc.check(); err != nil {
				return nil, err
			}
			ctc.mutation = mutation
			if node, err = ctc.sqlSave(ctx); err != nil {
				return nil, err
			}
			mutation.id = &node.ID
			mutation.done = true
			return node, err
		})
		for i := len(ctc.hooks) - 1; i >= 0; i-- {
			if ctc.hooks[i] == nil {
				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
			}
			mut = ctc.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, ctc.mutation); err != nil {
			return nil, err
		}
	}
	return node, err
}

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

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

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

// defaults sets the default values of the builder before save.
func (ctc *CaseTriageCreate) defaults() {
	if _, ok := ctc.mutation.CreatedAt(); !ok {
		v := casetriage.DefaultCreatedAt()
		ctc.mutation.SetCreatedAt(v)
	}
	if _, ok := ctc.mutation.UpdatedAt(); !ok {
		v := casetriage.DefaultUpdatedAt()
		ctc.mutation.SetUpdatedAt(v)
	}
	if _, ok := ctc.mutation.Reason(); !ok {
		v := casetriage.DefaultReason
		ctc.mutation.SetReason(v)
	}
	if _, ok := ctc.mutation.Solution(); !ok {
		v := casetriage.DefaultSolution
		ctc.mutation.SetSolution(v)
	}
	if _, ok := ctc.mutation.IssueLink(); !ok {
		v := casetriage.DefaultIssueLink
		ctc.mutation.SetIssueLink(v)
	}
	if _, ok := ctc.mutation.Note(); !ok {
		v := casetriage.DefaultNote
		ctc.mutation.SetNote(v)
	}
	if _, ok := ctc.mutation.ForkedFrom(); !ok {
		v := casetriage.DefaultForkedFrom
		ctc.mutation.SetForkedFrom(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (ctc *CaseTriageCreate) check() error {
	if _, ok := ctc.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "CaseTriage.createdAt"`)}
	}
	if _, ok := ctc.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updatedAt", err: errors.New(`ent: missing required field "CaseTriage.updatedAt"`)}
	}
	if _, ok := ctc.mutation.PlanExecutionID(); !ok {
		return &ValidationError{Name: "planExecutionID", err: errors.New(`ent: missing required field "CaseTriage.planExecutionID"`)}
	}
	if v, ok := ctc.mutation.PlanExecutionID(); ok {
		if err := casetriage.PlanExecutionIDValidator(uint64(v)); err != nil {
			return &ValidationError{Name: "planExecutionID", err: fmt.Errorf(`ent: validator failed for field "CaseTriage.planExecutionID": %w`, err)}
		}
	}
	if _, ok := ctc.mutation.PlanID(); !ok {
		return &ValidationError{Name: "planID", err: errors.New(`ent: missing required field "CaseTriage.planID"`)}
	}
	if v, ok := ctc.mutation.PlanID(); ok {
		if err := casetriage.PlanIDValidator(uint64(v)); err != nil {
			return &ValidationError{Name: "planID", err: fmt.Errorf(`ent: validator failed for field "CaseTriage.planID": %w`, err)}
		}
	}
	if _, ok := ctc.mutation.CaseExecutionID(); !ok {
		return &ValidationError{Name: "caseExecutionID", err: errors.New(`ent: missing required field "CaseTriage.caseExecutionID"`)}
	}
	if v, ok := ctc.mutation.CaseExecutionID(); ok {
		if err := casetriage.CaseExecutionIDValidator(uint64(v)); err != nil {
			return &ValidationError{Name: "caseExecutionID", err: fmt.Errorf(`ent: validator failed for field "CaseTriage.caseExecutionID": %w`, err)}
		}
	}
	if _, ok := ctc.mutation.CaseID(); !ok {
		return &ValidationError{Name: "caseID", err: errors.New(`ent: missing required field "CaseTriage.caseID"`)}
	}
	if v, ok := ctc.mutation.CaseID(); ok {
		if err := casetriage.CaseIDValidator(uint64(v)); err != nil {
			return &ValidationError{Name: "caseID", err: fmt.Errorf(`ent: validator failed for field "CaseTriage.caseID": %w`, err)}
		}
	}
	if _, ok := ctc.mutation.Reason(); !ok {
		return &ValidationError{Name: "reason", err: errors.New(`ent: missing required field "CaseTriage.reason"`)}
	}
	if v, ok := ctc.mutation.Reason(); ok {
		if err := casetriage.ReasonValidator(v); err != nil {
			return &ValidationError{Name: "reason", err: fmt.Errorf(`ent: validator failed for field "CaseTriage.reason": %w`, err)}
		}
	}
	if _, ok := ctc.mutation.Solution(); !ok {
		return &ValidationError{Name: "solution", err: errors.New(`ent: missing required field "CaseTriage.solution"`)}
	}
	if v, ok := ctc.mutation.Solution(); ok {
		if err := casetriage.SolutionValidator(v); err != nil {
			return &ValidationError{Name: "solution", err: fmt.Errorf(`ent: validator failed for field "CaseTriage.solution": %w`, err)}
		}
	}
	if _, ok := ctc.mutation.IssueLink(); !ok {
		return &ValidationError{Name: "issueLink", err: errors.New(`ent: missing required field "CaseTriage.issueLink"`)}
	}
	if v, ok := ctc.mutation.IssueLink(); ok {
		if err := casetriage.IssueLinkValidator(v); err != nil {
			return &ValidationError{Name: "issueLink", err: fmt.Errorf(`ent: validator failed for field "CaseTriage.issueLink": %w`, err)}
		}
	}
	if _, ok := ctc.mutation.Note(); !ok {
		return &ValidationError{Name: "note", err: errors.New(`ent: missing required field "CaseTriage.note"`)}
	}
	if v, ok := ctc.mutation.Note(); ok {
		if err := casetriage.NoteValidator(v); err != nil {
			return &ValidationError{Name: "note", err: fmt.Errorf(`ent: validator failed for field "CaseTriage.note": %w`, err)}
		}
	}
	if _, ok := ctc.mutation.ForkedFrom(); !ok {
		return &ValidationError{Name: "forkedFrom", err: errors.New(`ent: missing required field "CaseTriage.forkedFrom"`)}
	}
	return nil
}

func (ctc *CaseTriageCreate) sqlSave(ctx context.Context) (*CaseTriage, error) {
	_node, _spec := ctc.createSpec()
	if err := sqlgraph.CreateNode(ctx, ctc.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{err.Error(), err}
		}
		return nil, err
	}
	if _spec.ID.Value != _node.ID {
		id := _spec.ID.Value.(int64)
		_node.ID = model.ID(id)
	}
	return _node, nil
}

func (ctc *CaseTriageCreate) createSpec() (*CaseTriage, *sqlgraph.CreateSpec) {
	var (
		_node = &CaseTriage{config: ctc.config}
		_spec = &sqlgraph.CreateSpec{
			Table: casetriage.Table,
			ID: &sqlgraph.FieldSpec{
				Type:   field.TypeUint64,
				Column: casetriage.FieldID,
			},
		}
	)
	_spec.Schema = ctc.schemaConfig.CaseTriage
	_spec.OnConflict = ctc.conflict
	if id, ok := ctc.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = id
	}
	if value, ok := ctc.mutation.CreatedAt(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeTime,
			Value:  value,
			Column: casetriage.FieldCreatedAt,
		})
		_node.CreatedAt = value
	}
	if value, ok := ctc.mutation.UpdatedAt(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeTime,
			Value:  value,
			Column: casetriage.FieldUpdatedAt,
		})
		_node.UpdatedAt = value
	}
	if value, ok := ctc.mutation.PlanExecutionID(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeUint64,
			Value:  value,
			Column: casetriage.FieldPlanExecutionID,
		})
		_node.PlanExecutionID = value
	}
	if value, ok := ctc.mutation.PlanID(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeUint64,
			Value:  value,
			Column: casetriage.FieldPlanID,
		})
		_node.PlanID = value
	}
	if value, ok := ctc.mutation.CaseExecutionID(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeUint64,
			Value:  value,
			Column: casetriage.FieldCaseExecutionID,
		})
		_node.CaseExecutionID = value
	}
	if value, ok := ctc.mutation.CaseID(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeUint64,
			Value:  value,
			Column: casetriage.FieldCaseID,
		})
		_node.CaseID = value
	}
	if value, ok := ctc.mutation.Reason(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeEnum,
			Value:  value,
			Column: casetriage.FieldReason,
		})
		_node.Reason = value
	}
	if value, ok := ctc.mutation.Solution(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeEnum,
			Value:  value,
			Column: casetriage.FieldSolution,
		})
		_node.Solution = value
	}
	if value, ok := ctc.mutation.IssueLink(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Value:  value,
			Column: casetriage.FieldIssueLink,
		})
		_node.IssueLink = value
	}
	if value, ok := ctc.mutation.Note(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeString,
			Value:  value,
			Column: casetriage.FieldNote,
		})
		_node.Note = value
	}
	if value, ok := ctc.mutation.ForkedFrom(); ok {
		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
			Type:   field.TypeUint64,
			Value:  value,
			Column: casetriage.FieldForkedFrom,
		})
		_node.ForkedFrom = value
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.CaseTriage.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.CaseTriageUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
//
func (ctc *CaseTriageCreate) OnConflict(opts ...sql.ConflictOption) *CaseTriageUpsertOne {
	ctc.conflict = opts
	return &CaseTriageUpsertOne{
		create: ctc,
	}
}

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

type (
	// CaseTriageUpsertOne is the builder for "upsert"-ing
	//  one CaseTriage node.
	CaseTriageUpsertOne struct {
		create *CaseTriageCreate
	}

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

// SetCreatedAt sets the "createdAt" field.
func (u *CaseTriageUpsert) SetCreatedAt(v time.Time) *CaseTriageUpsert {
	u.Set(casetriage.FieldCreatedAt, v)
	return u
}

// UpdateCreatedAt sets the "createdAt" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdateCreatedAt() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldCreatedAt)
	return u
}

// SetUpdatedAt sets the "updatedAt" field.
func (u *CaseTriageUpsert) SetUpdatedAt(v time.Time) *CaseTriageUpsert {
	u.Set(casetriage.FieldUpdatedAt, v)
	return u
}

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

// SetPlanExecutionID sets the "planExecutionID" field.
func (u *CaseTriageUpsert) SetPlanExecutionID(v model.ID) *CaseTriageUpsert {
	u.Set(casetriage.FieldPlanExecutionID, v)
	return u
}

// UpdatePlanExecutionID sets the "planExecutionID" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdatePlanExecutionID() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldPlanExecutionID)
	return u
}

// AddPlanExecutionID adds v to the "planExecutionID" field.
func (u *CaseTriageUpsert) AddPlanExecutionID(v model.ID) *CaseTriageUpsert {
	u.Add(casetriage.FieldPlanExecutionID, v)
	return u
}

// SetPlanID sets the "planID" field.
func (u *CaseTriageUpsert) SetPlanID(v model.ID) *CaseTriageUpsert {
	u.Set(casetriage.FieldPlanID, v)
	return u
}

// UpdatePlanID sets the "planID" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdatePlanID() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldPlanID)
	return u
}

// AddPlanID adds v to the "planID" field.
func (u *CaseTriageUpsert) AddPlanID(v model.ID) *CaseTriageUpsert {
	u.Add(casetriage.FieldPlanID, v)
	return u
}

// SetCaseExecutionID sets the "caseExecutionID" field.
func (u *CaseTriageUpsert) SetCaseExecutionID(v model.ID) *CaseTriageUpsert {
	u.Set(casetriage.FieldCaseExecutionID, v)
	return u
}

// UpdateCaseExecutionID sets the "caseExecutionID" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdateCaseExecutionID() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldCaseExecutionID)
	return u
}

// AddCaseExecutionID adds v to the "caseExecutionID" field.
func (u *CaseTriageUpsert) AddCaseExecutionID(v model.ID) *CaseTriageUpsert {
	u.Add(casetriage.FieldCaseExecutionID, v)
	return u
}

// SetCaseID sets the "caseID" field.
func (u *CaseTriageUpsert) SetCaseID(v model.ID) *CaseTriageUpsert {
	u.Set(casetriage.FieldCaseID, v)
	return u
}

// UpdateCaseID sets the "caseID" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdateCaseID() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldCaseID)
	return u
}

// AddCaseID adds v to the "caseID" field.
func (u *CaseTriageUpsert) AddCaseID(v model.ID) *CaseTriageUpsert {
	u.Add(casetriage.FieldCaseID, v)
	return u
}

// SetReason sets the "reason" field.
func (u *CaseTriageUpsert) SetReason(v model.CaseExecFailReason) *CaseTriageUpsert {
	u.Set(casetriage.FieldReason, v)
	return u
}

// UpdateReason sets the "reason" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdateReason() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldReason)
	return u
}

// SetSolution sets the "solution" field.
func (u *CaseTriageUpsert) SetSolution(v model.ExecFailSolution) *CaseTriageUpsert {
	u.Set(casetriage.FieldSolution, v)
	return u
}

// UpdateSolution sets the "solution" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdateSolution() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldSolution)
	return u
}

// SetIssueLink sets the "issueLink" field.
func (u *CaseTriageUpsert) SetIssueLink(v string) *CaseTriageUpsert {
	u.Set(casetriage.FieldIssueLink, v)
	return u
}

// UpdateIssueLink sets the "issueLink" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdateIssueLink() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldIssueLink)
	return u
}

// SetNote sets the "note" field.
func (u *CaseTriageUpsert) SetNote(v string) *CaseTriageUpsert {
	u.Set(casetriage.FieldNote, v)
	return u
}

// UpdateNote sets the "note" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdateNote() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldNote)
	return u
}

// SetForkedFrom sets the "forkedFrom" field.
func (u *CaseTriageUpsert) SetForkedFrom(v model.ID) *CaseTriageUpsert {
	u.Set(casetriage.FieldForkedFrom, v)
	return u
}

// UpdateForkedFrom sets the "forkedFrom" field to the value that was provided on create.
func (u *CaseTriageUpsert) UpdateForkedFrom() *CaseTriageUpsert {
	u.SetExcluded(casetriage.FieldForkedFrom)
	return u
}

// AddForkedFrom adds v to the "forkedFrom" field.
func (u *CaseTriageUpsert) AddForkedFrom(v model.ID) *CaseTriageUpsert {
	u.Add(casetriage.FieldForkedFrom, v)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
// Using this option is equivalent to using:
//
//	client.CaseTriage.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(casetriage.FieldID)
//			}),
//		).
//		Exec(ctx)
//
func (u *CaseTriageUpsertOne) UpdateNewValues() *CaseTriageUpsertOne {
	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.ID(); exists {
			s.SetIgnore(casetriage.FieldID)
		}
		if _, exists := u.create.mutation.CreatedAt(); exists {
			s.SetIgnore(casetriage.FieldCreatedAt)
		}
		if _, exists := u.create.mutation.UpdatedAt(); exists {
			s.SetIgnore(casetriage.FieldUpdatedAt)
		}
		if _, exists := u.create.mutation.PlanExecutionID(); exists {
			s.SetIgnore(casetriage.FieldPlanExecutionID)
		}
		if _, exists := u.create.mutation.PlanID(); exists {
			s.SetIgnore(casetriage.FieldPlanID)
		}
		if _, exists := u.create.mutation.CaseExecutionID(); exists {
			s.SetIgnore(casetriage.FieldCaseExecutionID)
		}
		if _, exists := u.create.mutation.CaseID(); exists {
			s.SetIgnore(casetriage.FieldCaseID)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//  client.CaseTriage.Create().
//      OnConflict(sql.ResolveWithIgnore()).
//      Exec(ctx)
//
func (u *CaseTriageUpsertOne) Ignore() *CaseTriageUpsertOne {
	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 *CaseTriageUpsertOne) DoNothing() *CaseTriageUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

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

// SetCreatedAt sets the "createdAt" field.
func (u *CaseTriageUpsertOne) SetCreatedAt(v time.Time) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetCreatedAt(v)
	})
}

// UpdateCreatedAt sets the "createdAt" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdateCreatedAt() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateCreatedAt()
	})
}

// SetUpdatedAt sets the "updatedAt" field.
func (u *CaseTriageUpsertOne) SetUpdatedAt(v time.Time) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetUpdatedAt(v)
	})
}

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

// SetPlanExecutionID sets the "planExecutionID" field.
func (u *CaseTriageUpsertOne) SetPlanExecutionID(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetPlanExecutionID(v)
	})
}

// AddPlanExecutionID adds v to the "planExecutionID" field.
func (u *CaseTriageUpsertOne) AddPlanExecutionID(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddPlanExecutionID(v)
	})
}

// UpdatePlanExecutionID sets the "planExecutionID" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdatePlanExecutionID() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdatePlanExecutionID()
	})
}

// SetPlanID sets the "planID" field.
func (u *CaseTriageUpsertOne) SetPlanID(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetPlanID(v)
	})
}

// AddPlanID adds v to the "planID" field.
func (u *CaseTriageUpsertOne) AddPlanID(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddPlanID(v)
	})
}

// UpdatePlanID sets the "planID" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdatePlanID() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdatePlanID()
	})
}

// SetCaseExecutionID sets the "caseExecutionID" field.
func (u *CaseTriageUpsertOne) SetCaseExecutionID(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetCaseExecutionID(v)
	})
}

// AddCaseExecutionID adds v to the "caseExecutionID" field.
func (u *CaseTriageUpsertOne) AddCaseExecutionID(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddCaseExecutionID(v)
	})
}

// UpdateCaseExecutionID sets the "caseExecutionID" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdateCaseExecutionID() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateCaseExecutionID()
	})
}

// SetCaseID sets the "caseID" field.
func (u *CaseTriageUpsertOne) SetCaseID(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetCaseID(v)
	})
}

// AddCaseID adds v to the "caseID" field.
func (u *CaseTriageUpsertOne) AddCaseID(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddCaseID(v)
	})
}

// UpdateCaseID sets the "caseID" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdateCaseID() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateCaseID()
	})
}

// SetReason sets the "reason" field.
func (u *CaseTriageUpsertOne) SetReason(v model.CaseExecFailReason) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetReason(v)
	})
}

// UpdateReason sets the "reason" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdateReason() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateReason()
	})
}

// SetSolution sets the "solution" field.
func (u *CaseTriageUpsertOne) SetSolution(v model.ExecFailSolution) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetSolution(v)
	})
}

// UpdateSolution sets the "solution" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdateSolution() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateSolution()
	})
}

// SetIssueLink sets the "issueLink" field.
func (u *CaseTriageUpsertOne) SetIssueLink(v string) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetIssueLink(v)
	})
}

// UpdateIssueLink sets the "issueLink" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdateIssueLink() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateIssueLink()
	})
}

// SetNote sets the "note" field.
func (u *CaseTriageUpsertOne) SetNote(v string) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetNote(v)
	})
}

// UpdateNote sets the "note" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdateNote() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateNote()
	})
}

// SetForkedFrom sets the "forkedFrom" field.
func (u *CaseTriageUpsertOne) SetForkedFrom(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetForkedFrom(v)
	})
}

// AddForkedFrom adds v to the "forkedFrom" field.
func (u *CaseTriageUpsertOne) AddForkedFrom(v model.ID) *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddForkedFrom(v)
	})
}

// UpdateForkedFrom sets the "forkedFrom" field to the value that was provided on create.
func (u *CaseTriageUpsertOne) UpdateForkedFrom() *CaseTriageUpsertOne {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateForkedFrom()
	})
}

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

// ExecX is like Exec, but panics if an error occurs.
func (u *CaseTriageUpsertOne) 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 *CaseTriageUpsertOne) ID(ctx context.Context) (id model.ID, 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 *CaseTriageUpsertOne) IDX(ctx context.Context) model.ID {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// CaseTriageCreateBulk is the builder for creating many CaseTriage entities in bulk.
type CaseTriageCreateBulk struct {
	config
	builders []*CaseTriageCreate
	conflict []sql.ConflictOption
}

// Save creates the CaseTriage entities in the database.
func (ctcb *CaseTriageCreateBulk) Save(ctx context.Context) ([]*CaseTriage, error) {
	specs := make([]*sqlgraph.CreateSpec, len(ctcb.builders))
	nodes := make([]*CaseTriage, len(ctcb.builders))
	mutators := make([]Mutator, len(ctcb.builders))
	for i := range ctcb.builders {
		func(i int, root context.Context) {
			builder := ctcb.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*CaseTriageMutation)
				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, ctcb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = ctcb.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, ctcb.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 && nodes[i].ID == 0 {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = model.ID(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, ctcb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

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

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

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

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.CaseTriage.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.CaseTriageUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
//
func (ctcb *CaseTriageCreateBulk) OnConflict(opts ...sql.ConflictOption) *CaseTriageUpsertBulk {
	ctcb.conflict = opts
	return &CaseTriageUpsertBulk{
		create: ctcb,
	}
}

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

// CaseTriageUpsertBulk is the builder for "upsert"-ing
// a bulk of CaseTriage nodes.
type CaseTriageUpsertBulk struct {
	create *CaseTriageCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.CaseTriage.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(casetriage.FieldID)
//			}),
//		).
//		Exec(ctx)
//
func (u *CaseTriageUpsertBulk) UpdateNewValues() *CaseTriageUpsertBulk {
	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.ID(); exists {
				s.SetIgnore(casetriage.FieldID)
				return
			}
			if _, exists := b.mutation.CreatedAt(); exists {
				s.SetIgnore(casetriage.FieldCreatedAt)
			}
			if _, exists := b.mutation.UpdatedAt(); exists {
				s.SetIgnore(casetriage.FieldUpdatedAt)
			}
			if _, exists := b.mutation.PlanExecutionID(); exists {
				s.SetIgnore(casetriage.FieldPlanExecutionID)
			}
			if _, exists := b.mutation.PlanID(); exists {
				s.SetIgnore(casetriage.FieldPlanID)
			}
			if _, exists := b.mutation.CaseExecutionID(); exists {
				s.SetIgnore(casetriage.FieldCaseExecutionID)
			}
			if _, exists := b.mutation.CaseID(); exists {
				s.SetIgnore(casetriage.FieldCaseID)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.CaseTriage.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
//
func (u *CaseTriageUpsertBulk) Ignore() *CaseTriageUpsertBulk {
	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 *CaseTriageUpsertBulk) DoNothing() *CaseTriageUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

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

// SetCreatedAt sets the "createdAt" field.
func (u *CaseTriageUpsertBulk) SetCreatedAt(v time.Time) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetCreatedAt(v)
	})
}

// UpdateCreatedAt sets the "createdAt" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdateCreatedAt() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateCreatedAt()
	})
}

// SetUpdatedAt sets the "updatedAt" field.
func (u *CaseTriageUpsertBulk) SetUpdatedAt(v time.Time) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetUpdatedAt(v)
	})
}

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

// SetPlanExecutionID sets the "planExecutionID" field.
func (u *CaseTriageUpsertBulk) SetPlanExecutionID(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetPlanExecutionID(v)
	})
}

// AddPlanExecutionID adds v to the "planExecutionID" field.
func (u *CaseTriageUpsertBulk) AddPlanExecutionID(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddPlanExecutionID(v)
	})
}

// UpdatePlanExecutionID sets the "planExecutionID" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdatePlanExecutionID() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdatePlanExecutionID()
	})
}

// SetPlanID sets the "planID" field.
func (u *CaseTriageUpsertBulk) SetPlanID(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetPlanID(v)
	})
}

// AddPlanID adds v to the "planID" field.
func (u *CaseTriageUpsertBulk) AddPlanID(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddPlanID(v)
	})
}

// UpdatePlanID sets the "planID" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdatePlanID() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdatePlanID()
	})
}

// SetCaseExecutionID sets the "caseExecutionID" field.
func (u *CaseTriageUpsertBulk) SetCaseExecutionID(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetCaseExecutionID(v)
	})
}

// AddCaseExecutionID adds v to the "caseExecutionID" field.
func (u *CaseTriageUpsertBulk) AddCaseExecutionID(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddCaseExecutionID(v)
	})
}

// UpdateCaseExecutionID sets the "caseExecutionID" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdateCaseExecutionID() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateCaseExecutionID()
	})
}

// SetCaseID sets the "caseID" field.
func (u *CaseTriageUpsertBulk) SetCaseID(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetCaseID(v)
	})
}

// AddCaseID adds v to the "caseID" field.
func (u *CaseTriageUpsertBulk) AddCaseID(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddCaseID(v)
	})
}

// UpdateCaseID sets the "caseID" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdateCaseID() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateCaseID()
	})
}

// SetReason sets the "reason" field.
func (u *CaseTriageUpsertBulk) SetReason(v model.CaseExecFailReason) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetReason(v)
	})
}

// UpdateReason sets the "reason" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdateReason() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateReason()
	})
}

// SetSolution sets the "solution" field.
func (u *CaseTriageUpsertBulk) SetSolution(v model.ExecFailSolution) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetSolution(v)
	})
}

// UpdateSolution sets the "solution" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdateSolution() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateSolution()
	})
}

// SetIssueLink sets the "issueLink" field.
func (u *CaseTriageUpsertBulk) SetIssueLink(v string) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetIssueLink(v)
	})
}

// UpdateIssueLink sets the "issueLink" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdateIssueLink() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateIssueLink()
	})
}

// SetNote sets the "note" field.
func (u *CaseTriageUpsertBulk) SetNote(v string) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetNote(v)
	})
}

// UpdateNote sets the "note" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdateNote() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateNote()
	})
}

// SetForkedFrom sets the "forkedFrom" field.
func (u *CaseTriageUpsertBulk) SetForkedFrom(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.SetForkedFrom(v)
	})
}

// AddForkedFrom adds v to the "forkedFrom" field.
func (u *CaseTriageUpsertBulk) AddForkedFrom(v model.ID) *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.AddForkedFrom(v)
	})
}

// UpdateForkedFrom sets the "forkedFrom" field to the value that was provided on create.
func (u *CaseTriageUpsertBulk) UpdateForkedFrom() *CaseTriageUpsertBulk {
	return u.Update(func(s *CaseTriageUpsert) {
		s.UpdateForkedFrom()
	})
}

// Exec executes the query.
func (u *CaseTriageUpsertBulk) Exec(ctx context.Context) error {
	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 CaseTriageCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for CaseTriageCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

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