// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"registry-backend/ent/ciworkflowresult"
	"registry-backend/ent/gitcommit"
	"registry-backend/ent/predicate"
	"registry-backend/ent/schema"
	"registry-backend/ent/storagefile"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/google/uuid"
)

// CIWorkflowResultUpdate is the builder for updating CIWorkflowResult entities.
type CIWorkflowResultUpdate struct {
	config
	hooks     []Hook
	mutation  *CIWorkflowResultMutation
	modifiers []func(*sql.UpdateBuilder)
}

// Where appends a list predicates to the CIWorkflowResultUpdate builder.
func (cwru *CIWorkflowResultUpdate) Where(ps ...predicate.CIWorkflowResult) *CIWorkflowResultUpdate {
	cwru.mutation.Where(ps...)
	return cwru
}

// SetUpdateTime sets the "update_time" field.
func (cwru *CIWorkflowResultUpdate) SetUpdateTime(t time.Time) *CIWorkflowResultUpdate {
	cwru.mutation.SetUpdateTime(t)
	return cwru
}

// SetOperatingSystem sets the "operating_system" field.
func (cwru *CIWorkflowResultUpdate) SetOperatingSystem(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetOperatingSystem(s)
	return cwru
}

// SetNillableOperatingSystem sets the "operating_system" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableOperatingSystem(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetOperatingSystem(*s)
	}
	return cwru
}

// SetWorkflowName sets the "workflow_name" field.
func (cwru *CIWorkflowResultUpdate) SetWorkflowName(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetWorkflowName(s)
	return cwru
}

// SetNillableWorkflowName sets the "workflow_name" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableWorkflowName(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetWorkflowName(*s)
	}
	return cwru
}

// ClearWorkflowName clears the value of the "workflow_name" field.
func (cwru *CIWorkflowResultUpdate) ClearWorkflowName() *CIWorkflowResultUpdate {
	cwru.mutation.ClearWorkflowName()
	return cwru
}

// SetRunID sets the "run_id" field.
func (cwru *CIWorkflowResultUpdate) SetRunID(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetRunID(s)
	return cwru
}

// SetNillableRunID sets the "run_id" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableRunID(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetRunID(*s)
	}
	return cwru
}

// ClearRunID clears the value of the "run_id" field.
func (cwru *CIWorkflowResultUpdate) ClearRunID() *CIWorkflowResultUpdate {
	cwru.mutation.ClearRunID()
	return cwru
}

// SetJobID sets the "job_id" field.
func (cwru *CIWorkflowResultUpdate) SetJobID(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetJobID(s)
	return cwru
}

// SetNillableJobID sets the "job_id" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableJobID(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetJobID(*s)
	}
	return cwru
}

// ClearJobID clears the value of the "job_id" field.
func (cwru *CIWorkflowResultUpdate) ClearJobID() *CIWorkflowResultUpdate {
	cwru.mutation.ClearJobID()
	return cwru
}

// SetStatus sets the "status" field.
func (cwru *CIWorkflowResultUpdate) SetStatus(srst schema.WorkflowRunStatusType) *CIWorkflowResultUpdate {
	cwru.mutation.SetStatus(srst)
	return cwru
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableStatus(srst *schema.WorkflowRunStatusType) *CIWorkflowResultUpdate {
	if srst != nil {
		cwru.SetStatus(*srst)
	}
	return cwru
}

// SetStartTime sets the "start_time" field.
func (cwru *CIWorkflowResultUpdate) SetStartTime(i int64) *CIWorkflowResultUpdate {
	cwru.mutation.ResetStartTime()
	cwru.mutation.SetStartTime(i)
	return cwru
}

// SetNillableStartTime sets the "start_time" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableStartTime(i *int64) *CIWorkflowResultUpdate {
	if i != nil {
		cwru.SetStartTime(*i)
	}
	return cwru
}

// AddStartTime adds i to the "start_time" field.
func (cwru *CIWorkflowResultUpdate) AddStartTime(i int64) *CIWorkflowResultUpdate {
	cwru.mutation.AddStartTime(i)
	return cwru
}

// ClearStartTime clears the value of the "start_time" field.
func (cwru *CIWorkflowResultUpdate) ClearStartTime() *CIWorkflowResultUpdate {
	cwru.mutation.ClearStartTime()
	return cwru
}

// SetEndTime sets the "end_time" field.
func (cwru *CIWorkflowResultUpdate) SetEndTime(i int64) *CIWorkflowResultUpdate {
	cwru.mutation.ResetEndTime()
	cwru.mutation.SetEndTime(i)
	return cwru
}

// SetNillableEndTime sets the "end_time" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableEndTime(i *int64) *CIWorkflowResultUpdate {
	if i != nil {
		cwru.SetEndTime(*i)
	}
	return cwru
}

// AddEndTime adds i to the "end_time" field.
func (cwru *CIWorkflowResultUpdate) AddEndTime(i int64) *CIWorkflowResultUpdate {
	cwru.mutation.AddEndTime(i)
	return cwru
}

// ClearEndTime clears the value of the "end_time" field.
func (cwru *CIWorkflowResultUpdate) ClearEndTime() *CIWorkflowResultUpdate {
	cwru.mutation.ClearEndTime()
	return cwru
}

// SetPythonVersion sets the "python_version" field.
func (cwru *CIWorkflowResultUpdate) SetPythonVersion(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetPythonVersion(s)
	return cwru
}

// SetNillablePythonVersion sets the "python_version" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillablePythonVersion(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetPythonVersion(*s)
	}
	return cwru
}

// ClearPythonVersion clears the value of the "python_version" field.
func (cwru *CIWorkflowResultUpdate) ClearPythonVersion() *CIWorkflowResultUpdate {
	cwru.mutation.ClearPythonVersion()
	return cwru
}

// SetPytorchVersion sets the "pytorch_version" field.
func (cwru *CIWorkflowResultUpdate) SetPytorchVersion(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetPytorchVersion(s)
	return cwru
}

// SetNillablePytorchVersion sets the "pytorch_version" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillablePytorchVersion(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetPytorchVersion(*s)
	}
	return cwru
}

// ClearPytorchVersion clears the value of the "pytorch_version" field.
func (cwru *CIWorkflowResultUpdate) ClearPytorchVersion() *CIWorkflowResultUpdate {
	cwru.mutation.ClearPytorchVersion()
	return cwru
}

// SetCudaVersion sets the "cuda_version" field.
func (cwru *CIWorkflowResultUpdate) SetCudaVersion(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetCudaVersion(s)
	return cwru
}

// SetNillableCudaVersion sets the "cuda_version" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableCudaVersion(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetCudaVersion(*s)
	}
	return cwru
}

// ClearCudaVersion clears the value of the "cuda_version" field.
func (cwru *CIWorkflowResultUpdate) ClearCudaVersion() *CIWorkflowResultUpdate {
	cwru.mutation.ClearCudaVersion()
	return cwru
}

// SetComfyRunFlags sets the "comfy_run_flags" field.
func (cwru *CIWorkflowResultUpdate) SetComfyRunFlags(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetComfyRunFlags(s)
	return cwru
}

// SetNillableComfyRunFlags sets the "comfy_run_flags" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableComfyRunFlags(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetComfyRunFlags(*s)
	}
	return cwru
}

// ClearComfyRunFlags clears the value of the "comfy_run_flags" field.
func (cwru *CIWorkflowResultUpdate) ClearComfyRunFlags() *CIWorkflowResultUpdate {
	cwru.mutation.ClearComfyRunFlags()
	return cwru
}

// SetAvgVram sets the "avg_vram" field.
func (cwru *CIWorkflowResultUpdate) SetAvgVram(i int) *CIWorkflowResultUpdate {
	cwru.mutation.ResetAvgVram()
	cwru.mutation.SetAvgVram(i)
	return cwru
}

// SetNillableAvgVram sets the "avg_vram" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableAvgVram(i *int) *CIWorkflowResultUpdate {
	if i != nil {
		cwru.SetAvgVram(*i)
	}
	return cwru
}

// AddAvgVram adds i to the "avg_vram" field.
func (cwru *CIWorkflowResultUpdate) AddAvgVram(i int) *CIWorkflowResultUpdate {
	cwru.mutation.AddAvgVram(i)
	return cwru
}

// ClearAvgVram clears the value of the "avg_vram" field.
func (cwru *CIWorkflowResultUpdate) ClearAvgVram() *CIWorkflowResultUpdate {
	cwru.mutation.ClearAvgVram()
	return cwru
}

// SetPeakVram sets the "peak_vram" field.
func (cwru *CIWorkflowResultUpdate) SetPeakVram(i int) *CIWorkflowResultUpdate {
	cwru.mutation.ResetPeakVram()
	cwru.mutation.SetPeakVram(i)
	return cwru
}

// SetNillablePeakVram sets the "peak_vram" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillablePeakVram(i *int) *CIWorkflowResultUpdate {
	if i != nil {
		cwru.SetPeakVram(*i)
	}
	return cwru
}

// AddPeakVram adds i to the "peak_vram" field.
func (cwru *CIWorkflowResultUpdate) AddPeakVram(i int) *CIWorkflowResultUpdate {
	cwru.mutation.AddPeakVram(i)
	return cwru
}

// ClearPeakVram clears the value of the "peak_vram" field.
func (cwru *CIWorkflowResultUpdate) ClearPeakVram() *CIWorkflowResultUpdate {
	cwru.mutation.ClearPeakVram()
	return cwru
}

// SetJobTriggerUser sets the "job_trigger_user" field.
func (cwru *CIWorkflowResultUpdate) SetJobTriggerUser(s string) *CIWorkflowResultUpdate {
	cwru.mutation.SetJobTriggerUser(s)
	return cwru
}

// SetNillableJobTriggerUser sets the "job_trigger_user" field if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableJobTriggerUser(s *string) *CIWorkflowResultUpdate {
	if s != nil {
		cwru.SetJobTriggerUser(*s)
	}
	return cwru
}

// ClearJobTriggerUser clears the value of the "job_trigger_user" field.
func (cwru *CIWorkflowResultUpdate) ClearJobTriggerUser() *CIWorkflowResultUpdate {
	cwru.mutation.ClearJobTriggerUser()
	return cwru
}

// SetMetadata sets the "metadata" field.
func (cwru *CIWorkflowResultUpdate) SetMetadata(m map[string]interface{}) *CIWorkflowResultUpdate {
	cwru.mutation.SetMetadata(m)
	return cwru
}

// ClearMetadata clears the value of the "metadata" field.
func (cwru *CIWorkflowResultUpdate) ClearMetadata() *CIWorkflowResultUpdate {
	cwru.mutation.ClearMetadata()
	return cwru
}

// SetGitcommitID sets the "gitcommit" edge to the GitCommit entity by ID.
func (cwru *CIWorkflowResultUpdate) SetGitcommitID(id uuid.UUID) *CIWorkflowResultUpdate {
	cwru.mutation.SetGitcommitID(id)
	return cwru
}

// SetNillableGitcommitID sets the "gitcommit" edge to the GitCommit entity by ID if the given value is not nil.
func (cwru *CIWorkflowResultUpdate) SetNillableGitcommitID(id *uuid.UUID) *CIWorkflowResultUpdate {
	if id != nil {
		cwru = cwru.SetGitcommitID(*id)
	}
	return cwru
}

// SetGitcommit sets the "gitcommit" edge to the GitCommit entity.
func (cwru *CIWorkflowResultUpdate) SetGitcommit(g *GitCommit) *CIWorkflowResultUpdate {
	return cwru.SetGitcommitID(g.ID)
}

// AddStorageFileIDs adds the "storage_file" edge to the StorageFile entity by IDs.
func (cwru *CIWorkflowResultUpdate) AddStorageFileIDs(ids ...uuid.UUID) *CIWorkflowResultUpdate {
	cwru.mutation.AddStorageFileIDs(ids...)
	return cwru
}

// AddStorageFile adds the "storage_file" edges to the StorageFile entity.
func (cwru *CIWorkflowResultUpdate) AddStorageFile(s ...*StorageFile) *CIWorkflowResultUpdate {
	ids := make([]uuid.UUID, len(s))
	for i := range s {
		ids[i] = s[i].ID
	}
	return cwru.AddStorageFileIDs(ids...)
}

// Mutation returns the CIWorkflowResultMutation object of the builder.
func (cwru *CIWorkflowResultUpdate) Mutation() *CIWorkflowResultMutation {
	return cwru.mutation
}

// ClearGitcommit clears the "gitcommit" edge to the GitCommit entity.
func (cwru *CIWorkflowResultUpdate) ClearGitcommit() *CIWorkflowResultUpdate {
	cwru.mutation.ClearGitcommit()
	return cwru
}

// ClearStorageFile clears all "storage_file" edges to the StorageFile entity.
func (cwru *CIWorkflowResultUpdate) ClearStorageFile() *CIWorkflowResultUpdate {
	cwru.mutation.ClearStorageFile()
	return cwru
}

// RemoveStorageFileIDs removes the "storage_file" edge to StorageFile entities by IDs.
func (cwru *CIWorkflowResultUpdate) RemoveStorageFileIDs(ids ...uuid.UUID) *CIWorkflowResultUpdate {
	cwru.mutation.RemoveStorageFileIDs(ids...)
	return cwru
}

// RemoveStorageFile removes "storage_file" edges to StorageFile entities.
func (cwru *CIWorkflowResultUpdate) RemoveStorageFile(s ...*StorageFile) *CIWorkflowResultUpdate {
	ids := make([]uuid.UUID, len(s))
	for i := range s {
		ids[i] = s[i].ID
	}
	return cwru.RemoveStorageFileIDs(ids...)
}

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

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

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

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

// defaults sets the default values of the builder before save.
func (cwru *CIWorkflowResultUpdate) defaults() {
	if _, ok := cwru.mutation.UpdateTime(); !ok {
		v := ciworkflowresult.UpdateDefaultUpdateTime()
		cwru.mutation.SetUpdateTime(v)
	}
}

// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (cwru *CIWorkflowResultUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CIWorkflowResultUpdate {
	cwru.modifiers = append(cwru.modifiers, modifiers...)
	return cwru
}

func (cwru *CIWorkflowResultUpdate) sqlSave(ctx context.Context) (n int, err error) {
	_spec := sqlgraph.NewUpdateSpec(ciworkflowresult.Table, ciworkflowresult.Columns, sqlgraph.NewFieldSpec(ciworkflowresult.FieldID, field.TypeUUID))
	if ps := cwru.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := cwru.mutation.UpdateTime(); ok {
		_spec.SetField(ciworkflowresult.FieldUpdateTime, field.TypeTime, value)
	}
	if value, ok := cwru.mutation.OperatingSystem(); ok {
		_spec.SetField(ciworkflowresult.FieldOperatingSystem, field.TypeString, value)
	}
	if value, ok := cwru.mutation.WorkflowName(); ok {
		_spec.SetField(ciworkflowresult.FieldWorkflowName, field.TypeString, value)
	}
	if cwru.mutation.WorkflowNameCleared() {
		_spec.ClearField(ciworkflowresult.FieldWorkflowName, field.TypeString)
	}
	if value, ok := cwru.mutation.RunID(); ok {
		_spec.SetField(ciworkflowresult.FieldRunID, field.TypeString, value)
	}
	if cwru.mutation.RunIDCleared() {
		_spec.ClearField(ciworkflowresult.FieldRunID, field.TypeString)
	}
	if value, ok := cwru.mutation.JobID(); ok {
		_spec.SetField(ciworkflowresult.FieldJobID, field.TypeString, value)
	}
	if cwru.mutation.JobIDCleared() {
		_spec.ClearField(ciworkflowresult.FieldJobID, field.TypeString)
	}
	if value, ok := cwru.mutation.Status(); ok {
		_spec.SetField(ciworkflowresult.FieldStatus, field.TypeString, value)
	}
	if value, ok := cwru.mutation.StartTime(); ok {
		_spec.SetField(ciworkflowresult.FieldStartTime, field.TypeInt64, value)
	}
	if value, ok := cwru.mutation.AddedStartTime(); ok {
		_spec.AddField(ciworkflowresult.FieldStartTime, field.TypeInt64, value)
	}
	if cwru.mutation.StartTimeCleared() {
		_spec.ClearField(ciworkflowresult.FieldStartTime, field.TypeInt64)
	}
	if value, ok := cwru.mutation.EndTime(); ok {
		_spec.SetField(ciworkflowresult.FieldEndTime, field.TypeInt64, value)
	}
	if value, ok := cwru.mutation.AddedEndTime(); ok {
		_spec.AddField(ciworkflowresult.FieldEndTime, field.TypeInt64, value)
	}
	if cwru.mutation.EndTimeCleared() {
		_spec.ClearField(ciworkflowresult.FieldEndTime, field.TypeInt64)
	}
	if value, ok := cwru.mutation.PythonVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldPythonVersion, field.TypeString, value)
	}
	if cwru.mutation.PythonVersionCleared() {
		_spec.ClearField(ciworkflowresult.FieldPythonVersion, field.TypeString)
	}
	if value, ok := cwru.mutation.PytorchVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldPytorchVersion, field.TypeString, value)
	}
	if cwru.mutation.PytorchVersionCleared() {
		_spec.ClearField(ciworkflowresult.FieldPytorchVersion, field.TypeString)
	}
	if value, ok := cwru.mutation.CudaVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldCudaVersion, field.TypeString, value)
	}
	if cwru.mutation.CudaVersionCleared() {
		_spec.ClearField(ciworkflowresult.FieldCudaVersion, field.TypeString)
	}
	if value, ok := cwru.mutation.ComfyRunFlags(); ok {
		_spec.SetField(ciworkflowresult.FieldComfyRunFlags, field.TypeString, value)
	}
	if cwru.mutation.ComfyRunFlagsCleared() {
		_spec.ClearField(ciworkflowresult.FieldComfyRunFlags, field.TypeString)
	}
	if value, ok := cwru.mutation.AvgVram(); ok {
		_spec.SetField(ciworkflowresult.FieldAvgVram, field.TypeInt, value)
	}
	if value, ok := cwru.mutation.AddedAvgVram(); ok {
		_spec.AddField(ciworkflowresult.FieldAvgVram, field.TypeInt, value)
	}
	if cwru.mutation.AvgVramCleared() {
		_spec.ClearField(ciworkflowresult.FieldAvgVram, field.TypeInt)
	}
	if value, ok := cwru.mutation.PeakVram(); ok {
		_spec.SetField(ciworkflowresult.FieldPeakVram, field.TypeInt, value)
	}
	if value, ok := cwru.mutation.AddedPeakVram(); ok {
		_spec.AddField(ciworkflowresult.FieldPeakVram, field.TypeInt, value)
	}
	if cwru.mutation.PeakVramCleared() {
		_spec.ClearField(ciworkflowresult.FieldPeakVram, field.TypeInt)
	}
	if value, ok := cwru.mutation.JobTriggerUser(); ok {
		_spec.SetField(ciworkflowresult.FieldJobTriggerUser, field.TypeString, value)
	}
	if cwru.mutation.JobTriggerUserCleared() {
		_spec.ClearField(ciworkflowresult.FieldJobTriggerUser, field.TypeString)
	}
	if value, ok := cwru.mutation.Metadata(); ok {
		_spec.SetField(ciworkflowresult.FieldMetadata, field.TypeJSON, value)
	}
	if cwru.mutation.MetadataCleared() {
		_spec.ClearField(ciworkflowresult.FieldMetadata, field.TypeJSON)
	}
	if cwru.mutation.GitcommitCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   ciworkflowresult.GitcommitTable,
			Columns: []string{ciworkflowresult.GitcommitColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(gitcommit.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := cwru.mutation.GitcommitIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   ciworkflowresult.GitcommitTable,
			Columns: []string{ciworkflowresult.GitcommitColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(gitcommit.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if cwru.mutation.StorageFileCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   ciworkflowresult.StorageFileTable,
			Columns: []string{ciworkflowresult.StorageFileColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(storagefile.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := cwru.mutation.RemovedStorageFileIDs(); len(nodes) > 0 && !cwru.mutation.StorageFileCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   ciworkflowresult.StorageFileTable,
			Columns: []string{ciworkflowresult.StorageFileColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(storagefile.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := cwru.mutation.StorageFileIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   ciworkflowresult.StorageFileTable,
			Columns: []string{ciworkflowresult.StorageFileColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(storagefile.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_spec.AddModifiers(cwru.modifiers...)
	if n, err = sqlgraph.UpdateNodes(ctx, cwru.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{ciworkflowresult.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	cwru.mutation.done = true
	return n, nil
}

// CIWorkflowResultUpdateOne is the builder for updating a single CIWorkflowResult entity.
type CIWorkflowResultUpdateOne struct {
	config
	fields    []string
	hooks     []Hook
	mutation  *CIWorkflowResultMutation
	modifiers []func(*sql.UpdateBuilder)
}

// SetUpdateTime sets the "update_time" field.
func (cwruo *CIWorkflowResultUpdateOne) SetUpdateTime(t time.Time) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetUpdateTime(t)
	return cwruo
}

// SetOperatingSystem sets the "operating_system" field.
func (cwruo *CIWorkflowResultUpdateOne) SetOperatingSystem(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetOperatingSystem(s)
	return cwruo
}

// SetNillableOperatingSystem sets the "operating_system" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableOperatingSystem(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetOperatingSystem(*s)
	}
	return cwruo
}

// SetWorkflowName sets the "workflow_name" field.
func (cwruo *CIWorkflowResultUpdateOne) SetWorkflowName(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetWorkflowName(s)
	return cwruo
}

// SetNillableWorkflowName sets the "workflow_name" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableWorkflowName(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetWorkflowName(*s)
	}
	return cwruo
}

// ClearWorkflowName clears the value of the "workflow_name" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearWorkflowName() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearWorkflowName()
	return cwruo
}

// SetRunID sets the "run_id" field.
func (cwruo *CIWorkflowResultUpdateOne) SetRunID(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetRunID(s)
	return cwruo
}

// SetNillableRunID sets the "run_id" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableRunID(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetRunID(*s)
	}
	return cwruo
}

// ClearRunID clears the value of the "run_id" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearRunID() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearRunID()
	return cwruo
}

// SetJobID sets the "job_id" field.
func (cwruo *CIWorkflowResultUpdateOne) SetJobID(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetJobID(s)
	return cwruo
}

// SetNillableJobID sets the "job_id" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableJobID(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetJobID(*s)
	}
	return cwruo
}

// ClearJobID clears the value of the "job_id" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearJobID() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearJobID()
	return cwruo
}

// SetStatus sets the "status" field.
func (cwruo *CIWorkflowResultUpdateOne) SetStatus(srst schema.WorkflowRunStatusType) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetStatus(srst)
	return cwruo
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableStatus(srst *schema.WorkflowRunStatusType) *CIWorkflowResultUpdateOne {
	if srst != nil {
		cwruo.SetStatus(*srst)
	}
	return cwruo
}

// SetStartTime sets the "start_time" field.
func (cwruo *CIWorkflowResultUpdateOne) SetStartTime(i int64) *CIWorkflowResultUpdateOne {
	cwruo.mutation.ResetStartTime()
	cwruo.mutation.SetStartTime(i)
	return cwruo
}

// SetNillableStartTime sets the "start_time" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableStartTime(i *int64) *CIWorkflowResultUpdateOne {
	if i != nil {
		cwruo.SetStartTime(*i)
	}
	return cwruo
}

// AddStartTime adds i to the "start_time" field.
func (cwruo *CIWorkflowResultUpdateOne) AddStartTime(i int64) *CIWorkflowResultUpdateOne {
	cwruo.mutation.AddStartTime(i)
	return cwruo
}

// ClearStartTime clears the value of the "start_time" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearStartTime() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearStartTime()
	return cwruo
}

// SetEndTime sets the "end_time" field.
func (cwruo *CIWorkflowResultUpdateOne) SetEndTime(i int64) *CIWorkflowResultUpdateOne {
	cwruo.mutation.ResetEndTime()
	cwruo.mutation.SetEndTime(i)
	return cwruo
}

// SetNillableEndTime sets the "end_time" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableEndTime(i *int64) *CIWorkflowResultUpdateOne {
	if i != nil {
		cwruo.SetEndTime(*i)
	}
	return cwruo
}

// AddEndTime adds i to the "end_time" field.
func (cwruo *CIWorkflowResultUpdateOne) AddEndTime(i int64) *CIWorkflowResultUpdateOne {
	cwruo.mutation.AddEndTime(i)
	return cwruo
}

// ClearEndTime clears the value of the "end_time" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearEndTime() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearEndTime()
	return cwruo
}

// SetPythonVersion sets the "python_version" field.
func (cwruo *CIWorkflowResultUpdateOne) SetPythonVersion(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetPythonVersion(s)
	return cwruo
}

// SetNillablePythonVersion sets the "python_version" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillablePythonVersion(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetPythonVersion(*s)
	}
	return cwruo
}

// ClearPythonVersion clears the value of the "python_version" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearPythonVersion() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearPythonVersion()
	return cwruo
}

// SetPytorchVersion sets the "pytorch_version" field.
func (cwruo *CIWorkflowResultUpdateOne) SetPytorchVersion(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetPytorchVersion(s)
	return cwruo
}

// SetNillablePytorchVersion sets the "pytorch_version" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillablePytorchVersion(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetPytorchVersion(*s)
	}
	return cwruo
}

// ClearPytorchVersion clears the value of the "pytorch_version" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearPytorchVersion() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearPytorchVersion()
	return cwruo
}

// SetCudaVersion sets the "cuda_version" field.
func (cwruo *CIWorkflowResultUpdateOne) SetCudaVersion(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetCudaVersion(s)
	return cwruo
}

// SetNillableCudaVersion sets the "cuda_version" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableCudaVersion(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetCudaVersion(*s)
	}
	return cwruo
}

// ClearCudaVersion clears the value of the "cuda_version" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearCudaVersion() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearCudaVersion()
	return cwruo
}

// SetComfyRunFlags sets the "comfy_run_flags" field.
func (cwruo *CIWorkflowResultUpdateOne) SetComfyRunFlags(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetComfyRunFlags(s)
	return cwruo
}

// SetNillableComfyRunFlags sets the "comfy_run_flags" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableComfyRunFlags(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetComfyRunFlags(*s)
	}
	return cwruo
}

// ClearComfyRunFlags clears the value of the "comfy_run_flags" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearComfyRunFlags() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearComfyRunFlags()
	return cwruo
}

// SetAvgVram sets the "avg_vram" field.
func (cwruo *CIWorkflowResultUpdateOne) SetAvgVram(i int) *CIWorkflowResultUpdateOne {
	cwruo.mutation.ResetAvgVram()
	cwruo.mutation.SetAvgVram(i)
	return cwruo
}

// SetNillableAvgVram sets the "avg_vram" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableAvgVram(i *int) *CIWorkflowResultUpdateOne {
	if i != nil {
		cwruo.SetAvgVram(*i)
	}
	return cwruo
}

// AddAvgVram adds i to the "avg_vram" field.
func (cwruo *CIWorkflowResultUpdateOne) AddAvgVram(i int) *CIWorkflowResultUpdateOne {
	cwruo.mutation.AddAvgVram(i)
	return cwruo
}

// ClearAvgVram clears the value of the "avg_vram" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearAvgVram() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearAvgVram()
	return cwruo
}

// SetPeakVram sets the "peak_vram" field.
func (cwruo *CIWorkflowResultUpdateOne) SetPeakVram(i int) *CIWorkflowResultUpdateOne {
	cwruo.mutation.ResetPeakVram()
	cwruo.mutation.SetPeakVram(i)
	return cwruo
}

// SetNillablePeakVram sets the "peak_vram" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillablePeakVram(i *int) *CIWorkflowResultUpdateOne {
	if i != nil {
		cwruo.SetPeakVram(*i)
	}
	return cwruo
}

// AddPeakVram adds i to the "peak_vram" field.
func (cwruo *CIWorkflowResultUpdateOne) AddPeakVram(i int) *CIWorkflowResultUpdateOne {
	cwruo.mutation.AddPeakVram(i)
	return cwruo
}

// ClearPeakVram clears the value of the "peak_vram" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearPeakVram() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearPeakVram()
	return cwruo
}

// SetJobTriggerUser sets the "job_trigger_user" field.
func (cwruo *CIWorkflowResultUpdateOne) SetJobTriggerUser(s string) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetJobTriggerUser(s)
	return cwruo
}

// SetNillableJobTriggerUser sets the "job_trigger_user" field if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableJobTriggerUser(s *string) *CIWorkflowResultUpdateOne {
	if s != nil {
		cwruo.SetJobTriggerUser(*s)
	}
	return cwruo
}

// ClearJobTriggerUser clears the value of the "job_trigger_user" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearJobTriggerUser() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearJobTriggerUser()
	return cwruo
}

// SetMetadata sets the "metadata" field.
func (cwruo *CIWorkflowResultUpdateOne) SetMetadata(m map[string]interface{}) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetMetadata(m)
	return cwruo
}

// ClearMetadata clears the value of the "metadata" field.
func (cwruo *CIWorkflowResultUpdateOne) ClearMetadata() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearMetadata()
	return cwruo
}

// SetGitcommitID sets the "gitcommit" edge to the GitCommit entity by ID.
func (cwruo *CIWorkflowResultUpdateOne) SetGitcommitID(id uuid.UUID) *CIWorkflowResultUpdateOne {
	cwruo.mutation.SetGitcommitID(id)
	return cwruo
}

// SetNillableGitcommitID sets the "gitcommit" edge to the GitCommit entity by ID if the given value is not nil.
func (cwruo *CIWorkflowResultUpdateOne) SetNillableGitcommitID(id *uuid.UUID) *CIWorkflowResultUpdateOne {
	if id != nil {
		cwruo = cwruo.SetGitcommitID(*id)
	}
	return cwruo
}

// SetGitcommit sets the "gitcommit" edge to the GitCommit entity.
func (cwruo *CIWorkflowResultUpdateOne) SetGitcommit(g *GitCommit) *CIWorkflowResultUpdateOne {
	return cwruo.SetGitcommitID(g.ID)
}

// AddStorageFileIDs adds the "storage_file" edge to the StorageFile entity by IDs.
func (cwruo *CIWorkflowResultUpdateOne) AddStorageFileIDs(ids ...uuid.UUID) *CIWorkflowResultUpdateOne {
	cwruo.mutation.AddStorageFileIDs(ids...)
	return cwruo
}

// AddStorageFile adds the "storage_file" edges to the StorageFile entity.
func (cwruo *CIWorkflowResultUpdateOne) AddStorageFile(s ...*StorageFile) *CIWorkflowResultUpdateOne {
	ids := make([]uuid.UUID, len(s))
	for i := range s {
		ids[i] = s[i].ID
	}
	return cwruo.AddStorageFileIDs(ids...)
}

// Mutation returns the CIWorkflowResultMutation object of the builder.
func (cwruo *CIWorkflowResultUpdateOne) Mutation() *CIWorkflowResultMutation {
	return cwruo.mutation
}

// ClearGitcommit clears the "gitcommit" edge to the GitCommit entity.
func (cwruo *CIWorkflowResultUpdateOne) ClearGitcommit() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearGitcommit()
	return cwruo
}

// ClearStorageFile clears all "storage_file" edges to the StorageFile entity.
func (cwruo *CIWorkflowResultUpdateOne) ClearStorageFile() *CIWorkflowResultUpdateOne {
	cwruo.mutation.ClearStorageFile()
	return cwruo
}

// RemoveStorageFileIDs removes the "storage_file" edge to StorageFile entities by IDs.
func (cwruo *CIWorkflowResultUpdateOne) RemoveStorageFileIDs(ids ...uuid.UUID) *CIWorkflowResultUpdateOne {
	cwruo.mutation.RemoveStorageFileIDs(ids...)
	return cwruo
}

// RemoveStorageFile removes "storage_file" edges to StorageFile entities.
func (cwruo *CIWorkflowResultUpdateOne) RemoveStorageFile(s ...*StorageFile) *CIWorkflowResultUpdateOne {
	ids := make([]uuid.UUID, len(s))
	for i := range s {
		ids[i] = s[i].ID
	}
	return cwruo.RemoveStorageFileIDs(ids...)
}

// Where appends a list predicates to the CIWorkflowResultUpdate builder.
func (cwruo *CIWorkflowResultUpdateOne) Where(ps ...predicate.CIWorkflowResult) *CIWorkflowResultUpdateOne {
	cwruo.mutation.Where(ps...)
	return cwruo
}

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

// Save executes the query and returns the updated CIWorkflowResult entity.
func (cwruo *CIWorkflowResultUpdateOne) Save(ctx context.Context) (*CIWorkflowResult, error) {
	cwruo.defaults()
	return withHooks(ctx, cwruo.sqlSave, cwruo.mutation, cwruo.hooks)
}

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

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

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

// defaults sets the default values of the builder before save.
func (cwruo *CIWorkflowResultUpdateOne) defaults() {
	if _, ok := cwruo.mutation.UpdateTime(); !ok {
		v := ciworkflowresult.UpdateDefaultUpdateTime()
		cwruo.mutation.SetUpdateTime(v)
	}
}

// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (cwruo *CIWorkflowResultUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CIWorkflowResultUpdateOne {
	cwruo.modifiers = append(cwruo.modifiers, modifiers...)
	return cwruo
}

func (cwruo *CIWorkflowResultUpdateOne) sqlSave(ctx context.Context) (_node *CIWorkflowResult, err error) {
	_spec := sqlgraph.NewUpdateSpec(ciworkflowresult.Table, ciworkflowresult.Columns, sqlgraph.NewFieldSpec(ciworkflowresult.FieldID, field.TypeUUID))
	id, ok := cwruo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CIWorkflowResult.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := cwruo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, ciworkflowresult.FieldID)
		for _, f := range fields {
			if !ciworkflowresult.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != ciworkflowresult.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := cwruo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := cwruo.mutation.UpdateTime(); ok {
		_spec.SetField(ciworkflowresult.FieldUpdateTime, field.TypeTime, value)
	}
	if value, ok := cwruo.mutation.OperatingSystem(); ok {
		_spec.SetField(ciworkflowresult.FieldOperatingSystem, field.TypeString, value)
	}
	if value, ok := cwruo.mutation.WorkflowName(); ok {
		_spec.SetField(ciworkflowresult.FieldWorkflowName, field.TypeString, value)
	}
	if cwruo.mutation.WorkflowNameCleared() {
		_spec.ClearField(ciworkflowresult.FieldWorkflowName, field.TypeString)
	}
	if value, ok := cwruo.mutation.RunID(); ok {
		_spec.SetField(ciworkflowresult.FieldRunID, field.TypeString, value)
	}
	if cwruo.mutation.RunIDCleared() {
		_spec.ClearField(ciworkflowresult.FieldRunID, field.TypeString)
	}
	if value, ok := cwruo.mutation.JobID(); ok {
		_spec.SetField(ciworkflowresult.FieldJobID, field.TypeString, value)
	}
	if cwruo.mutation.JobIDCleared() {
		_spec.ClearField(ciworkflowresult.FieldJobID, field.TypeString)
	}
	if value, ok := cwruo.mutation.Status(); ok {
		_spec.SetField(ciworkflowresult.FieldStatus, field.TypeString, value)
	}
	if value, ok := cwruo.mutation.StartTime(); ok {
		_spec.SetField(ciworkflowresult.FieldStartTime, field.TypeInt64, value)
	}
	if value, ok := cwruo.mutation.AddedStartTime(); ok {
		_spec.AddField(ciworkflowresult.FieldStartTime, field.TypeInt64, value)
	}
	if cwruo.mutation.StartTimeCleared() {
		_spec.ClearField(ciworkflowresult.FieldStartTime, field.TypeInt64)
	}
	if value, ok := cwruo.mutation.EndTime(); ok {
		_spec.SetField(ciworkflowresult.FieldEndTime, field.TypeInt64, value)
	}
	if value, ok := cwruo.mutation.AddedEndTime(); ok {
		_spec.AddField(ciworkflowresult.FieldEndTime, field.TypeInt64, value)
	}
	if cwruo.mutation.EndTimeCleared() {
		_spec.ClearField(ciworkflowresult.FieldEndTime, field.TypeInt64)
	}
	if value, ok := cwruo.mutation.PythonVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldPythonVersion, field.TypeString, value)
	}
	if cwruo.mutation.PythonVersionCleared() {
		_spec.ClearField(ciworkflowresult.FieldPythonVersion, field.TypeString)
	}
	if value, ok := cwruo.mutation.PytorchVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldPytorchVersion, field.TypeString, value)
	}
	if cwruo.mutation.PytorchVersionCleared() {
		_spec.ClearField(ciworkflowresult.FieldPytorchVersion, field.TypeString)
	}
	if value, ok := cwruo.mutation.CudaVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldCudaVersion, field.TypeString, value)
	}
	if cwruo.mutation.CudaVersionCleared() {
		_spec.ClearField(ciworkflowresult.FieldCudaVersion, field.TypeString)
	}
	if value, ok := cwruo.mutation.ComfyRunFlags(); ok {
		_spec.SetField(ciworkflowresult.FieldComfyRunFlags, field.TypeString, value)
	}
	if cwruo.mutation.ComfyRunFlagsCleared() {
		_spec.ClearField(ciworkflowresult.FieldComfyRunFlags, field.TypeString)
	}
	if value, ok := cwruo.mutation.AvgVram(); ok {
		_spec.SetField(ciworkflowresult.FieldAvgVram, field.TypeInt, value)
	}
	if value, ok := cwruo.mutation.AddedAvgVram(); ok {
		_spec.AddField(ciworkflowresult.FieldAvgVram, field.TypeInt, value)
	}
	if cwruo.mutation.AvgVramCleared() {
		_spec.ClearField(ciworkflowresult.FieldAvgVram, field.TypeInt)
	}
	if value, ok := cwruo.mutation.PeakVram(); ok {
		_spec.SetField(ciworkflowresult.FieldPeakVram, field.TypeInt, value)
	}
	if value, ok := cwruo.mutation.AddedPeakVram(); ok {
		_spec.AddField(ciworkflowresult.FieldPeakVram, field.TypeInt, value)
	}
	if cwruo.mutation.PeakVramCleared() {
		_spec.ClearField(ciworkflowresult.FieldPeakVram, field.TypeInt)
	}
	if value, ok := cwruo.mutation.JobTriggerUser(); ok {
		_spec.SetField(ciworkflowresult.FieldJobTriggerUser, field.TypeString, value)
	}
	if cwruo.mutation.JobTriggerUserCleared() {
		_spec.ClearField(ciworkflowresult.FieldJobTriggerUser, field.TypeString)
	}
	if value, ok := cwruo.mutation.Metadata(); ok {
		_spec.SetField(ciworkflowresult.FieldMetadata, field.TypeJSON, value)
	}
	if cwruo.mutation.MetadataCleared() {
		_spec.ClearField(ciworkflowresult.FieldMetadata, field.TypeJSON)
	}
	if cwruo.mutation.GitcommitCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   ciworkflowresult.GitcommitTable,
			Columns: []string{ciworkflowresult.GitcommitColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(gitcommit.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := cwruo.mutation.GitcommitIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   ciworkflowresult.GitcommitTable,
			Columns: []string{ciworkflowresult.GitcommitColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(gitcommit.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if cwruo.mutation.StorageFileCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   ciworkflowresult.StorageFileTable,
			Columns: []string{ciworkflowresult.StorageFileColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(storagefile.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := cwruo.mutation.RemovedStorageFileIDs(); len(nodes) > 0 && !cwruo.mutation.StorageFileCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   ciworkflowresult.StorageFileTable,
			Columns: []string{ciworkflowresult.StorageFileColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(storagefile.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := cwruo.mutation.StorageFileIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   ciworkflowresult.StorageFileTable,
			Columns: []string{ciworkflowresult.StorageFileColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(storagefile.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_spec.AddModifiers(cwruo.modifiers...)
	_node = &CIWorkflowResult{config: cwruo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, cwruo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{ciworkflowresult.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	cwruo.mutation.done = true
	return _node, nil
}
