// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/dialect/sql/sqljson"
	"entgo.io/ent/schema/field"
	"github.com/buildbarn/bb-portal/ent/gen/ent/outputgroup"
	"github.com/buildbarn/bb-portal/ent/gen/ent/predicate"
	"github.com/buildbarn/bb-portal/ent/gen/ent/targetcomplete"
	"github.com/buildbarn/bb-portal/ent/gen/ent/targetpair"
	"github.com/buildbarn/bb-portal/ent/gen/ent/testfile"
)

// TargetCompleteUpdate is the builder for updating TargetComplete entities.
type TargetCompleteUpdate struct {
	config
	hooks    []Hook
	mutation *TargetCompleteMutation
}

// Where appends a list predicates to the TargetCompleteUpdate builder.
func (tcu *TargetCompleteUpdate) Where(ps ...predicate.TargetComplete) *TargetCompleteUpdate {
	tcu.mutation.Where(ps...)
	return tcu
}

// SetSuccess sets the "success" field.
func (tcu *TargetCompleteUpdate) SetSuccess(b bool) *TargetCompleteUpdate {
	tcu.mutation.SetSuccess(b)
	return tcu
}

// SetNillableSuccess sets the "success" field if the given value is not nil.
func (tcu *TargetCompleteUpdate) SetNillableSuccess(b *bool) *TargetCompleteUpdate {
	if b != nil {
		tcu.SetSuccess(*b)
	}
	return tcu
}

// ClearSuccess clears the value of the "success" field.
func (tcu *TargetCompleteUpdate) ClearSuccess() *TargetCompleteUpdate {
	tcu.mutation.ClearSuccess()
	return tcu
}

// SetTag sets the "tag" field.
func (tcu *TargetCompleteUpdate) SetTag(s []string) *TargetCompleteUpdate {
	tcu.mutation.SetTag(s)
	return tcu
}

// AppendTag appends s to the "tag" field.
func (tcu *TargetCompleteUpdate) AppendTag(s []string) *TargetCompleteUpdate {
	tcu.mutation.AppendTag(s)
	return tcu
}

// ClearTag clears the value of the "tag" field.
func (tcu *TargetCompleteUpdate) ClearTag() *TargetCompleteUpdate {
	tcu.mutation.ClearTag()
	return tcu
}

// SetTargetKind sets the "target_kind" field.
func (tcu *TargetCompleteUpdate) SetTargetKind(s string) *TargetCompleteUpdate {
	tcu.mutation.SetTargetKind(s)
	return tcu
}

// SetNillableTargetKind sets the "target_kind" field if the given value is not nil.
func (tcu *TargetCompleteUpdate) SetNillableTargetKind(s *string) *TargetCompleteUpdate {
	if s != nil {
		tcu.SetTargetKind(*s)
	}
	return tcu
}

// ClearTargetKind clears the value of the "target_kind" field.
func (tcu *TargetCompleteUpdate) ClearTargetKind() *TargetCompleteUpdate {
	tcu.mutation.ClearTargetKind()
	return tcu
}

// SetEndTimeInMs sets the "end_time_in_ms" field.
func (tcu *TargetCompleteUpdate) SetEndTimeInMs(i int64) *TargetCompleteUpdate {
	tcu.mutation.ResetEndTimeInMs()
	tcu.mutation.SetEndTimeInMs(i)
	return tcu
}

// SetNillableEndTimeInMs sets the "end_time_in_ms" field if the given value is not nil.
func (tcu *TargetCompleteUpdate) SetNillableEndTimeInMs(i *int64) *TargetCompleteUpdate {
	if i != nil {
		tcu.SetEndTimeInMs(*i)
	}
	return tcu
}

// AddEndTimeInMs adds i to the "end_time_in_ms" field.
func (tcu *TargetCompleteUpdate) AddEndTimeInMs(i int64) *TargetCompleteUpdate {
	tcu.mutation.AddEndTimeInMs(i)
	return tcu
}

// ClearEndTimeInMs clears the value of the "end_time_in_ms" field.
func (tcu *TargetCompleteUpdate) ClearEndTimeInMs() *TargetCompleteUpdate {
	tcu.mutation.ClearEndTimeInMs()
	return tcu
}

// SetTestTimeoutSeconds sets the "test_timeout_seconds" field.
func (tcu *TargetCompleteUpdate) SetTestTimeoutSeconds(i int64) *TargetCompleteUpdate {
	tcu.mutation.ResetTestTimeoutSeconds()
	tcu.mutation.SetTestTimeoutSeconds(i)
	return tcu
}

// SetNillableTestTimeoutSeconds sets the "test_timeout_seconds" field if the given value is not nil.
func (tcu *TargetCompleteUpdate) SetNillableTestTimeoutSeconds(i *int64) *TargetCompleteUpdate {
	if i != nil {
		tcu.SetTestTimeoutSeconds(*i)
	}
	return tcu
}

// AddTestTimeoutSeconds adds i to the "test_timeout_seconds" field.
func (tcu *TargetCompleteUpdate) AddTestTimeoutSeconds(i int64) *TargetCompleteUpdate {
	tcu.mutation.AddTestTimeoutSeconds(i)
	return tcu
}

// ClearTestTimeoutSeconds clears the value of the "test_timeout_seconds" field.
func (tcu *TargetCompleteUpdate) ClearTestTimeoutSeconds() *TargetCompleteUpdate {
	tcu.mutation.ClearTestTimeoutSeconds()
	return tcu
}

// SetTestTimeout sets the "test_timeout" field.
func (tcu *TargetCompleteUpdate) SetTestTimeout(i int64) *TargetCompleteUpdate {
	tcu.mutation.ResetTestTimeout()
	tcu.mutation.SetTestTimeout(i)
	return tcu
}

// SetNillableTestTimeout sets the "test_timeout" field if the given value is not nil.
func (tcu *TargetCompleteUpdate) SetNillableTestTimeout(i *int64) *TargetCompleteUpdate {
	if i != nil {
		tcu.SetTestTimeout(*i)
	}
	return tcu
}

// AddTestTimeout adds i to the "test_timeout" field.
func (tcu *TargetCompleteUpdate) AddTestTimeout(i int64) *TargetCompleteUpdate {
	tcu.mutation.AddTestTimeout(i)
	return tcu
}

// ClearTestTimeout clears the value of the "test_timeout" field.
func (tcu *TargetCompleteUpdate) ClearTestTimeout() *TargetCompleteUpdate {
	tcu.mutation.ClearTestTimeout()
	return tcu
}

// SetTestSize sets the "test_size" field.
func (tcu *TargetCompleteUpdate) SetTestSize(ts targetcomplete.TestSize) *TargetCompleteUpdate {
	tcu.mutation.SetTestSize(ts)
	return tcu
}

// SetNillableTestSize sets the "test_size" field if the given value is not nil.
func (tcu *TargetCompleteUpdate) SetNillableTestSize(ts *targetcomplete.TestSize) *TargetCompleteUpdate {
	if ts != nil {
		tcu.SetTestSize(*ts)
	}
	return tcu
}

// ClearTestSize clears the value of the "test_size" field.
func (tcu *TargetCompleteUpdate) ClearTestSize() *TargetCompleteUpdate {
	tcu.mutation.ClearTestSize()
	return tcu
}

// SetTargetPairID sets the "target_pair" edge to the TargetPair entity by ID.
func (tcu *TargetCompleteUpdate) SetTargetPairID(id int) *TargetCompleteUpdate {
	tcu.mutation.SetTargetPairID(id)
	return tcu
}

// SetNillableTargetPairID sets the "target_pair" edge to the TargetPair entity by ID if the given value is not nil.
func (tcu *TargetCompleteUpdate) SetNillableTargetPairID(id *int) *TargetCompleteUpdate {
	if id != nil {
		tcu = tcu.SetTargetPairID(*id)
	}
	return tcu
}

// SetTargetPair sets the "target_pair" edge to the TargetPair entity.
func (tcu *TargetCompleteUpdate) SetTargetPair(t *TargetPair) *TargetCompleteUpdate {
	return tcu.SetTargetPairID(t.ID)
}

// AddImportantOutputIDs adds the "important_output" edge to the TestFile entity by IDs.
func (tcu *TargetCompleteUpdate) AddImportantOutputIDs(ids ...int) *TargetCompleteUpdate {
	tcu.mutation.AddImportantOutputIDs(ids...)
	return tcu
}

// AddImportantOutput adds the "important_output" edges to the TestFile entity.
func (tcu *TargetCompleteUpdate) AddImportantOutput(t ...*TestFile) *TargetCompleteUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tcu.AddImportantOutputIDs(ids...)
}

// AddDirectoryOutputIDs adds the "directory_output" edge to the TestFile entity by IDs.
func (tcu *TargetCompleteUpdate) AddDirectoryOutputIDs(ids ...int) *TargetCompleteUpdate {
	tcu.mutation.AddDirectoryOutputIDs(ids...)
	return tcu
}

// AddDirectoryOutput adds the "directory_output" edges to the TestFile entity.
func (tcu *TargetCompleteUpdate) AddDirectoryOutput(t ...*TestFile) *TargetCompleteUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tcu.AddDirectoryOutputIDs(ids...)
}

// SetOutputGroupID sets the "output_group" edge to the OutputGroup entity by ID.
func (tcu *TargetCompleteUpdate) SetOutputGroupID(id int) *TargetCompleteUpdate {
	tcu.mutation.SetOutputGroupID(id)
	return tcu
}

// SetNillableOutputGroupID sets the "output_group" edge to the OutputGroup entity by ID if the given value is not nil.
func (tcu *TargetCompleteUpdate) SetNillableOutputGroupID(id *int) *TargetCompleteUpdate {
	if id != nil {
		tcu = tcu.SetOutputGroupID(*id)
	}
	return tcu
}

// SetOutputGroup sets the "output_group" edge to the OutputGroup entity.
func (tcu *TargetCompleteUpdate) SetOutputGroup(o *OutputGroup) *TargetCompleteUpdate {
	return tcu.SetOutputGroupID(o.ID)
}

// Mutation returns the TargetCompleteMutation object of the builder.
func (tcu *TargetCompleteUpdate) Mutation() *TargetCompleteMutation {
	return tcu.mutation
}

// ClearTargetPair clears the "target_pair" edge to the TargetPair entity.
func (tcu *TargetCompleteUpdate) ClearTargetPair() *TargetCompleteUpdate {
	tcu.mutation.ClearTargetPair()
	return tcu
}

// ClearImportantOutput clears all "important_output" edges to the TestFile entity.
func (tcu *TargetCompleteUpdate) ClearImportantOutput() *TargetCompleteUpdate {
	tcu.mutation.ClearImportantOutput()
	return tcu
}

// RemoveImportantOutputIDs removes the "important_output" edge to TestFile entities by IDs.
func (tcu *TargetCompleteUpdate) RemoveImportantOutputIDs(ids ...int) *TargetCompleteUpdate {
	tcu.mutation.RemoveImportantOutputIDs(ids...)
	return tcu
}

// RemoveImportantOutput removes "important_output" edges to TestFile entities.
func (tcu *TargetCompleteUpdate) RemoveImportantOutput(t ...*TestFile) *TargetCompleteUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tcu.RemoveImportantOutputIDs(ids...)
}

// ClearDirectoryOutput clears all "directory_output" edges to the TestFile entity.
func (tcu *TargetCompleteUpdate) ClearDirectoryOutput() *TargetCompleteUpdate {
	tcu.mutation.ClearDirectoryOutput()
	return tcu
}

// RemoveDirectoryOutputIDs removes the "directory_output" edge to TestFile entities by IDs.
func (tcu *TargetCompleteUpdate) RemoveDirectoryOutputIDs(ids ...int) *TargetCompleteUpdate {
	tcu.mutation.RemoveDirectoryOutputIDs(ids...)
	return tcu
}

// RemoveDirectoryOutput removes "directory_output" edges to TestFile entities.
func (tcu *TargetCompleteUpdate) RemoveDirectoryOutput(t ...*TestFile) *TargetCompleteUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tcu.RemoveDirectoryOutputIDs(ids...)
}

// ClearOutputGroup clears the "output_group" edge to the OutputGroup entity.
func (tcu *TargetCompleteUpdate) ClearOutputGroup() *TargetCompleteUpdate {
	tcu.mutation.ClearOutputGroup()
	return tcu
}

// Save executes the query and returns the number of nodes affected by the update operation.
func (tcu *TargetCompleteUpdate) Save(ctx context.Context) (int, error) {
	return withHooks(ctx, tcu.sqlSave, tcu.mutation, tcu.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (tcu *TargetCompleteUpdate) SaveX(ctx context.Context) int {
	affected, err := tcu.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}

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

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

// check runs all checks and user-defined validators on the builder.
func (tcu *TargetCompleteUpdate) check() error {
	if v, ok := tcu.mutation.TestSize(); ok {
		if err := targetcomplete.TestSizeValidator(v); err != nil {
			return &ValidationError{Name: "test_size", err: fmt.Errorf(`ent: validator failed for field "TargetComplete.test_size": %w`, err)}
		}
	}
	return nil
}

func (tcu *TargetCompleteUpdate) sqlSave(ctx context.Context) (n int, err error) {
	if err := tcu.check(); err != nil {
		return n, err
	}
	_spec := sqlgraph.NewUpdateSpec(targetcomplete.Table, targetcomplete.Columns, sqlgraph.NewFieldSpec(targetcomplete.FieldID, field.TypeInt))
	if ps := tcu.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := tcu.mutation.Success(); ok {
		_spec.SetField(targetcomplete.FieldSuccess, field.TypeBool, value)
	}
	if tcu.mutation.SuccessCleared() {
		_spec.ClearField(targetcomplete.FieldSuccess, field.TypeBool)
	}
	if value, ok := tcu.mutation.Tag(); ok {
		_spec.SetField(targetcomplete.FieldTag, field.TypeJSON, value)
	}
	if value, ok := tcu.mutation.AppendedTag(); ok {
		_spec.AddModifier(func(u *sql.UpdateBuilder) {
			sqljson.Append(u, targetcomplete.FieldTag, value)
		})
	}
	if tcu.mutation.TagCleared() {
		_spec.ClearField(targetcomplete.FieldTag, field.TypeJSON)
	}
	if value, ok := tcu.mutation.TargetKind(); ok {
		_spec.SetField(targetcomplete.FieldTargetKind, field.TypeString, value)
	}
	if tcu.mutation.TargetKindCleared() {
		_spec.ClearField(targetcomplete.FieldTargetKind, field.TypeString)
	}
	if value, ok := tcu.mutation.EndTimeInMs(); ok {
		_spec.SetField(targetcomplete.FieldEndTimeInMs, field.TypeInt64, value)
	}
	if value, ok := tcu.mutation.AddedEndTimeInMs(); ok {
		_spec.AddField(targetcomplete.FieldEndTimeInMs, field.TypeInt64, value)
	}
	if tcu.mutation.EndTimeInMsCleared() {
		_spec.ClearField(targetcomplete.FieldEndTimeInMs, field.TypeInt64)
	}
	if value, ok := tcu.mutation.TestTimeoutSeconds(); ok {
		_spec.SetField(targetcomplete.FieldTestTimeoutSeconds, field.TypeInt64, value)
	}
	if value, ok := tcu.mutation.AddedTestTimeoutSeconds(); ok {
		_spec.AddField(targetcomplete.FieldTestTimeoutSeconds, field.TypeInt64, value)
	}
	if tcu.mutation.TestTimeoutSecondsCleared() {
		_spec.ClearField(targetcomplete.FieldTestTimeoutSeconds, field.TypeInt64)
	}
	if value, ok := tcu.mutation.TestTimeout(); ok {
		_spec.SetField(targetcomplete.FieldTestTimeout, field.TypeInt64, value)
	}
	if value, ok := tcu.mutation.AddedTestTimeout(); ok {
		_spec.AddField(targetcomplete.FieldTestTimeout, field.TypeInt64, value)
	}
	if tcu.mutation.TestTimeoutCleared() {
		_spec.ClearField(targetcomplete.FieldTestTimeout, field.TypeInt64)
	}
	if value, ok := tcu.mutation.TestSize(); ok {
		_spec.SetField(targetcomplete.FieldTestSize, field.TypeEnum, value)
	}
	if tcu.mutation.TestSizeCleared() {
		_spec.ClearField(targetcomplete.FieldTestSize, field.TypeEnum)
	}
	if tcu.mutation.TargetPairCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   targetcomplete.TargetPairTable,
			Columns: []string{targetcomplete.TargetPairColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(targetpair.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcu.mutation.TargetPairIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   targetcomplete.TargetPairTable,
			Columns: []string{targetcomplete.TargetPairColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(targetpair.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tcu.mutation.ImportantOutputCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.ImportantOutputTable,
			Columns: []string{targetcomplete.ImportantOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcu.mutation.RemovedImportantOutputIDs(); len(nodes) > 0 && !tcu.mutation.ImportantOutputCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.ImportantOutputTable,
			Columns: []string{targetcomplete.ImportantOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcu.mutation.ImportantOutputIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.ImportantOutputTable,
			Columns: []string{targetcomplete.ImportantOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tcu.mutation.DirectoryOutputCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.DirectoryOutputTable,
			Columns: []string{targetcomplete.DirectoryOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcu.mutation.RemovedDirectoryOutputIDs(); len(nodes) > 0 && !tcu.mutation.DirectoryOutputCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.DirectoryOutputTable,
			Columns: []string{targetcomplete.DirectoryOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcu.mutation.DirectoryOutputIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.DirectoryOutputTable,
			Columns: []string{targetcomplete.DirectoryOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tcu.mutation.OutputGroupCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   targetcomplete.OutputGroupTable,
			Columns: []string{targetcomplete.OutputGroupColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(outputgroup.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcu.mutation.OutputGroupIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   targetcomplete.OutputGroupTable,
			Columns: []string{targetcomplete.OutputGroupColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(outputgroup.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if n, err = sqlgraph.UpdateNodes(ctx, tcu.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{targetcomplete.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	tcu.mutation.done = true
	return n, nil
}

// TargetCompleteUpdateOne is the builder for updating a single TargetComplete entity.
type TargetCompleteUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *TargetCompleteMutation
}

// SetSuccess sets the "success" field.
func (tcuo *TargetCompleteUpdateOne) SetSuccess(b bool) *TargetCompleteUpdateOne {
	tcuo.mutation.SetSuccess(b)
	return tcuo
}

// SetNillableSuccess sets the "success" field if the given value is not nil.
func (tcuo *TargetCompleteUpdateOne) SetNillableSuccess(b *bool) *TargetCompleteUpdateOne {
	if b != nil {
		tcuo.SetSuccess(*b)
	}
	return tcuo
}

// ClearSuccess clears the value of the "success" field.
func (tcuo *TargetCompleteUpdateOne) ClearSuccess() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearSuccess()
	return tcuo
}

// SetTag sets the "tag" field.
func (tcuo *TargetCompleteUpdateOne) SetTag(s []string) *TargetCompleteUpdateOne {
	tcuo.mutation.SetTag(s)
	return tcuo
}

// AppendTag appends s to the "tag" field.
func (tcuo *TargetCompleteUpdateOne) AppendTag(s []string) *TargetCompleteUpdateOne {
	tcuo.mutation.AppendTag(s)
	return tcuo
}

// ClearTag clears the value of the "tag" field.
func (tcuo *TargetCompleteUpdateOne) ClearTag() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearTag()
	return tcuo
}

// SetTargetKind sets the "target_kind" field.
func (tcuo *TargetCompleteUpdateOne) SetTargetKind(s string) *TargetCompleteUpdateOne {
	tcuo.mutation.SetTargetKind(s)
	return tcuo
}

// SetNillableTargetKind sets the "target_kind" field if the given value is not nil.
func (tcuo *TargetCompleteUpdateOne) SetNillableTargetKind(s *string) *TargetCompleteUpdateOne {
	if s != nil {
		tcuo.SetTargetKind(*s)
	}
	return tcuo
}

// ClearTargetKind clears the value of the "target_kind" field.
func (tcuo *TargetCompleteUpdateOne) ClearTargetKind() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearTargetKind()
	return tcuo
}

// SetEndTimeInMs sets the "end_time_in_ms" field.
func (tcuo *TargetCompleteUpdateOne) SetEndTimeInMs(i int64) *TargetCompleteUpdateOne {
	tcuo.mutation.ResetEndTimeInMs()
	tcuo.mutation.SetEndTimeInMs(i)
	return tcuo
}

// SetNillableEndTimeInMs sets the "end_time_in_ms" field if the given value is not nil.
func (tcuo *TargetCompleteUpdateOne) SetNillableEndTimeInMs(i *int64) *TargetCompleteUpdateOne {
	if i != nil {
		tcuo.SetEndTimeInMs(*i)
	}
	return tcuo
}

// AddEndTimeInMs adds i to the "end_time_in_ms" field.
func (tcuo *TargetCompleteUpdateOne) AddEndTimeInMs(i int64) *TargetCompleteUpdateOne {
	tcuo.mutation.AddEndTimeInMs(i)
	return tcuo
}

// ClearEndTimeInMs clears the value of the "end_time_in_ms" field.
func (tcuo *TargetCompleteUpdateOne) ClearEndTimeInMs() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearEndTimeInMs()
	return tcuo
}

// SetTestTimeoutSeconds sets the "test_timeout_seconds" field.
func (tcuo *TargetCompleteUpdateOne) SetTestTimeoutSeconds(i int64) *TargetCompleteUpdateOne {
	tcuo.mutation.ResetTestTimeoutSeconds()
	tcuo.mutation.SetTestTimeoutSeconds(i)
	return tcuo
}

// SetNillableTestTimeoutSeconds sets the "test_timeout_seconds" field if the given value is not nil.
func (tcuo *TargetCompleteUpdateOne) SetNillableTestTimeoutSeconds(i *int64) *TargetCompleteUpdateOne {
	if i != nil {
		tcuo.SetTestTimeoutSeconds(*i)
	}
	return tcuo
}

// AddTestTimeoutSeconds adds i to the "test_timeout_seconds" field.
func (tcuo *TargetCompleteUpdateOne) AddTestTimeoutSeconds(i int64) *TargetCompleteUpdateOne {
	tcuo.mutation.AddTestTimeoutSeconds(i)
	return tcuo
}

// ClearTestTimeoutSeconds clears the value of the "test_timeout_seconds" field.
func (tcuo *TargetCompleteUpdateOne) ClearTestTimeoutSeconds() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearTestTimeoutSeconds()
	return tcuo
}

// SetTestTimeout sets the "test_timeout" field.
func (tcuo *TargetCompleteUpdateOne) SetTestTimeout(i int64) *TargetCompleteUpdateOne {
	tcuo.mutation.ResetTestTimeout()
	tcuo.mutation.SetTestTimeout(i)
	return tcuo
}

// SetNillableTestTimeout sets the "test_timeout" field if the given value is not nil.
func (tcuo *TargetCompleteUpdateOne) SetNillableTestTimeout(i *int64) *TargetCompleteUpdateOne {
	if i != nil {
		tcuo.SetTestTimeout(*i)
	}
	return tcuo
}

// AddTestTimeout adds i to the "test_timeout" field.
func (tcuo *TargetCompleteUpdateOne) AddTestTimeout(i int64) *TargetCompleteUpdateOne {
	tcuo.mutation.AddTestTimeout(i)
	return tcuo
}

// ClearTestTimeout clears the value of the "test_timeout" field.
func (tcuo *TargetCompleteUpdateOne) ClearTestTimeout() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearTestTimeout()
	return tcuo
}

// SetTestSize sets the "test_size" field.
func (tcuo *TargetCompleteUpdateOne) SetTestSize(ts targetcomplete.TestSize) *TargetCompleteUpdateOne {
	tcuo.mutation.SetTestSize(ts)
	return tcuo
}

// SetNillableTestSize sets the "test_size" field if the given value is not nil.
func (tcuo *TargetCompleteUpdateOne) SetNillableTestSize(ts *targetcomplete.TestSize) *TargetCompleteUpdateOne {
	if ts != nil {
		tcuo.SetTestSize(*ts)
	}
	return tcuo
}

// ClearTestSize clears the value of the "test_size" field.
func (tcuo *TargetCompleteUpdateOne) ClearTestSize() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearTestSize()
	return tcuo
}

// SetTargetPairID sets the "target_pair" edge to the TargetPair entity by ID.
func (tcuo *TargetCompleteUpdateOne) SetTargetPairID(id int) *TargetCompleteUpdateOne {
	tcuo.mutation.SetTargetPairID(id)
	return tcuo
}

// SetNillableTargetPairID sets the "target_pair" edge to the TargetPair entity by ID if the given value is not nil.
func (tcuo *TargetCompleteUpdateOne) SetNillableTargetPairID(id *int) *TargetCompleteUpdateOne {
	if id != nil {
		tcuo = tcuo.SetTargetPairID(*id)
	}
	return tcuo
}

// SetTargetPair sets the "target_pair" edge to the TargetPair entity.
func (tcuo *TargetCompleteUpdateOne) SetTargetPair(t *TargetPair) *TargetCompleteUpdateOne {
	return tcuo.SetTargetPairID(t.ID)
}

// AddImportantOutputIDs adds the "important_output" edge to the TestFile entity by IDs.
func (tcuo *TargetCompleteUpdateOne) AddImportantOutputIDs(ids ...int) *TargetCompleteUpdateOne {
	tcuo.mutation.AddImportantOutputIDs(ids...)
	return tcuo
}

// AddImportantOutput adds the "important_output" edges to the TestFile entity.
func (tcuo *TargetCompleteUpdateOne) AddImportantOutput(t ...*TestFile) *TargetCompleteUpdateOne {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tcuo.AddImportantOutputIDs(ids...)
}

// AddDirectoryOutputIDs adds the "directory_output" edge to the TestFile entity by IDs.
func (tcuo *TargetCompleteUpdateOne) AddDirectoryOutputIDs(ids ...int) *TargetCompleteUpdateOne {
	tcuo.mutation.AddDirectoryOutputIDs(ids...)
	return tcuo
}

// AddDirectoryOutput adds the "directory_output" edges to the TestFile entity.
func (tcuo *TargetCompleteUpdateOne) AddDirectoryOutput(t ...*TestFile) *TargetCompleteUpdateOne {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tcuo.AddDirectoryOutputIDs(ids...)
}

// SetOutputGroupID sets the "output_group" edge to the OutputGroup entity by ID.
func (tcuo *TargetCompleteUpdateOne) SetOutputGroupID(id int) *TargetCompleteUpdateOne {
	tcuo.mutation.SetOutputGroupID(id)
	return tcuo
}

// SetNillableOutputGroupID sets the "output_group" edge to the OutputGroup entity by ID if the given value is not nil.
func (tcuo *TargetCompleteUpdateOne) SetNillableOutputGroupID(id *int) *TargetCompleteUpdateOne {
	if id != nil {
		tcuo = tcuo.SetOutputGroupID(*id)
	}
	return tcuo
}

// SetOutputGroup sets the "output_group" edge to the OutputGroup entity.
func (tcuo *TargetCompleteUpdateOne) SetOutputGroup(o *OutputGroup) *TargetCompleteUpdateOne {
	return tcuo.SetOutputGroupID(o.ID)
}

// Mutation returns the TargetCompleteMutation object of the builder.
func (tcuo *TargetCompleteUpdateOne) Mutation() *TargetCompleteMutation {
	return tcuo.mutation
}

// ClearTargetPair clears the "target_pair" edge to the TargetPair entity.
func (tcuo *TargetCompleteUpdateOne) ClearTargetPair() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearTargetPair()
	return tcuo
}

// ClearImportantOutput clears all "important_output" edges to the TestFile entity.
func (tcuo *TargetCompleteUpdateOne) ClearImportantOutput() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearImportantOutput()
	return tcuo
}

// RemoveImportantOutputIDs removes the "important_output" edge to TestFile entities by IDs.
func (tcuo *TargetCompleteUpdateOne) RemoveImportantOutputIDs(ids ...int) *TargetCompleteUpdateOne {
	tcuo.mutation.RemoveImportantOutputIDs(ids...)
	return tcuo
}

// RemoveImportantOutput removes "important_output" edges to TestFile entities.
func (tcuo *TargetCompleteUpdateOne) RemoveImportantOutput(t ...*TestFile) *TargetCompleteUpdateOne {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tcuo.RemoveImportantOutputIDs(ids...)
}

// ClearDirectoryOutput clears all "directory_output" edges to the TestFile entity.
func (tcuo *TargetCompleteUpdateOne) ClearDirectoryOutput() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearDirectoryOutput()
	return tcuo
}

// RemoveDirectoryOutputIDs removes the "directory_output" edge to TestFile entities by IDs.
func (tcuo *TargetCompleteUpdateOne) RemoveDirectoryOutputIDs(ids ...int) *TargetCompleteUpdateOne {
	tcuo.mutation.RemoveDirectoryOutputIDs(ids...)
	return tcuo
}

// RemoveDirectoryOutput removes "directory_output" edges to TestFile entities.
func (tcuo *TargetCompleteUpdateOne) RemoveDirectoryOutput(t ...*TestFile) *TargetCompleteUpdateOne {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tcuo.RemoveDirectoryOutputIDs(ids...)
}

// ClearOutputGroup clears the "output_group" edge to the OutputGroup entity.
func (tcuo *TargetCompleteUpdateOne) ClearOutputGroup() *TargetCompleteUpdateOne {
	tcuo.mutation.ClearOutputGroup()
	return tcuo
}

// Where appends a list predicates to the TargetCompleteUpdate builder.
func (tcuo *TargetCompleteUpdateOne) Where(ps ...predicate.TargetComplete) *TargetCompleteUpdateOne {
	tcuo.mutation.Where(ps...)
	return tcuo
}

// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (tcuo *TargetCompleteUpdateOne) Select(field string, fields ...string) *TargetCompleteUpdateOne {
	tcuo.fields = append([]string{field}, fields...)
	return tcuo
}

// Save executes the query and returns the updated TargetComplete entity.
func (tcuo *TargetCompleteUpdateOne) Save(ctx context.Context) (*TargetComplete, error) {
	return withHooks(ctx, tcuo.sqlSave, tcuo.mutation, tcuo.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (tcuo *TargetCompleteUpdateOne) SaveX(ctx context.Context) *TargetComplete {
	node, err := tcuo.Save(ctx)
	if err != nil {
		panic(err)
	}
	return node
}

// Exec executes the query on the entity.
func (tcuo *TargetCompleteUpdateOne) Exec(ctx context.Context) error {
	_, err := tcuo.Save(ctx)
	return err
}

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

// check runs all checks and user-defined validators on the builder.
func (tcuo *TargetCompleteUpdateOne) check() error {
	if v, ok := tcuo.mutation.TestSize(); ok {
		if err := targetcomplete.TestSizeValidator(v); err != nil {
			return &ValidationError{Name: "test_size", err: fmt.Errorf(`ent: validator failed for field "TargetComplete.test_size": %w`, err)}
		}
	}
	return nil
}

func (tcuo *TargetCompleteUpdateOne) sqlSave(ctx context.Context) (_node *TargetComplete, err error) {
	if err := tcuo.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(targetcomplete.Table, targetcomplete.Columns, sqlgraph.NewFieldSpec(targetcomplete.FieldID, field.TypeInt))
	id, ok := tcuo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "TargetComplete.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := tcuo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, targetcomplete.FieldID)
		for _, f := range fields {
			if !targetcomplete.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != targetcomplete.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := tcuo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := tcuo.mutation.Success(); ok {
		_spec.SetField(targetcomplete.FieldSuccess, field.TypeBool, value)
	}
	if tcuo.mutation.SuccessCleared() {
		_spec.ClearField(targetcomplete.FieldSuccess, field.TypeBool)
	}
	if value, ok := tcuo.mutation.Tag(); ok {
		_spec.SetField(targetcomplete.FieldTag, field.TypeJSON, value)
	}
	if value, ok := tcuo.mutation.AppendedTag(); ok {
		_spec.AddModifier(func(u *sql.UpdateBuilder) {
			sqljson.Append(u, targetcomplete.FieldTag, value)
		})
	}
	if tcuo.mutation.TagCleared() {
		_spec.ClearField(targetcomplete.FieldTag, field.TypeJSON)
	}
	if value, ok := tcuo.mutation.TargetKind(); ok {
		_spec.SetField(targetcomplete.FieldTargetKind, field.TypeString, value)
	}
	if tcuo.mutation.TargetKindCleared() {
		_spec.ClearField(targetcomplete.FieldTargetKind, field.TypeString)
	}
	if value, ok := tcuo.mutation.EndTimeInMs(); ok {
		_spec.SetField(targetcomplete.FieldEndTimeInMs, field.TypeInt64, value)
	}
	if value, ok := tcuo.mutation.AddedEndTimeInMs(); ok {
		_spec.AddField(targetcomplete.FieldEndTimeInMs, field.TypeInt64, value)
	}
	if tcuo.mutation.EndTimeInMsCleared() {
		_spec.ClearField(targetcomplete.FieldEndTimeInMs, field.TypeInt64)
	}
	if value, ok := tcuo.mutation.TestTimeoutSeconds(); ok {
		_spec.SetField(targetcomplete.FieldTestTimeoutSeconds, field.TypeInt64, value)
	}
	if value, ok := tcuo.mutation.AddedTestTimeoutSeconds(); ok {
		_spec.AddField(targetcomplete.FieldTestTimeoutSeconds, field.TypeInt64, value)
	}
	if tcuo.mutation.TestTimeoutSecondsCleared() {
		_spec.ClearField(targetcomplete.FieldTestTimeoutSeconds, field.TypeInt64)
	}
	if value, ok := tcuo.mutation.TestTimeout(); ok {
		_spec.SetField(targetcomplete.FieldTestTimeout, field.TypeInt64, value)
	}
	if value, ok := tcuo.mutation.AddedTestTimeout(); ok {
		_spec.AddField(targetcomplete.FieldTestTimeout, field.TypeInt64, value)
	}
	if tcuo.mutation.TestTimeoutCleared() {
		_spec.ClearField(targetcomplete.FieldTestTimeout, field.TypeInt64)
	}
	if value, ok := tcuo.mutation.TestSize(); ok {
		_spec.SetField(targetcomplete.FieldTestSize, field.TypeEnum, value)
	}
	if tcuo.mutation.TestSizeCleared() {
		_spec.ClearField(targetcomplete.FieldTestSize, field.TypeEnum)
	}
	if tcuo.mutation.TargetPairCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   targetcomplete.TargetPairTable,
			Columns: []string{targetcomplete.TargetPairColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(targetpair.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcuo.mutation.TargetPairIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   targetcomplete.TargetPairTable,
			Columns: []string{targetcomplete.TargetPairColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(targetpair.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tcuo.mutation.ImportantOutputCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.ImportantOutputTable,
			Columns: []string{targetcomplete.ImportantOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcuo.mutation.RemovedImportantOutputIDs(); len(nodes) > 0 && !tcuo.mutation.ImportantOutputCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.ImportantOutputTable,
			Columns: []string{targetcomplete.ImportantOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcuo.mutation.ImportantOutputIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.ImportantOutputTable,
			Columns: []string{targetcomplete.ImportantOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tcuo.mutation.DirectoryOutputCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.DirectoryOutputTable,
			Columns: []string{targetcomplete.DirectoryOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcuo.mutation.RemovedDirectoryOutputIDs(); len(nodes) > 0 && !tcuo.mutation.DirectoryOutputCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.DirectoryOutputTable,
			Columns: []string{targetcomplete.DirectoryOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcuo.mutation.DirectoryOutputIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   targetcomplete.DirectoryOutputTable,
			Columns: []string{targetcomplete.DirectoryOutputColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tcuo.mutation.OutputGroupCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   targetcomplete.OutputGroupTable,
			Columns: []string{targetcomplete.OutputGroupColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(outputgroup.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tcuo.mutation.OutputGroupIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   targetcomplete.OutputGroupTable,
			Columns: []string{targetcomplete.OutputGroupColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(outputgroup.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_node = &TargetComplete{config: tcuo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, tcuo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{targetcomplete.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	tcuo.mutation.done = true
	return _node, nil
}
