// 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/schema/field"
	"github.com/buildbarn/bb-portal/ent/gen/ent/actionsummary"
	"github.com/buildbarn/bb-portal/ent/gen/ent/artifactmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/bazelinvocation"
	"github.com/buildbarn/bb-portal/ent/gen/ent/buildgraphmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/cumulativemetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/dynamicexecutionmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/memorymetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/metrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/networkmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/packagemetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/predicate"
	"github.com/buildbarn/bb-portal/ent/gen/ent/targetmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/timingmetrics"
)

// MetricsUpdate is the builder for updating Metrics entities.
type MetricsUpdate struct {
	config
	hooks    []Hook
	mutation *MetricsMutation
}

// Where appends a list predicates to the MetricsUpdate builder.
func (mu *MetricsUpdate) Where(ps ...predicate.Metrics) *MetricsUpdate {
	mu.mutation.Where(ps...)
	return mu
}

// SetBazelInvocationID sets the "bazel_invocation" edge to the BazelInvocation entity by ID.
func (mu *MetricsUpdate) SetBazelInvocationID(id int) *MetricsUpdate {
	mu.mutation.SetBazelInvocationID(id)
	return mu
}

// SetNillableBazelInvocationID sets the "bazel_invocation" edge to the BazelInvocation entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableBazelInvocationID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetBazelInvocationID(*id)
	}
	return mu
}

// SetBazelInvocation sets the "bazel_invocation" edge to the BazelInvocation entity.
func (mu *MetricsUpdate) SetBazelInvocation(b *BazelInvocation) *MetricsUpdate {
	return mu.SetBazelInvocationID(b.ID)
}

// SetActionSummaryID sets the "action_summary" edge to the ActionSummary entity by ID.
func (mu *MetricsUpdate) SetActionSummaryID(id int) *MetricsUpdate {
	mu.mutation.SetActionSummaryID(id)
	return mu
}

// SetNillableActionSummaryID sets the "action_summary" edge to the ActionSummary entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableActionSummaryID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetActionSummaryID(*id)
	}
	return mu
}

// SetActionSummary sets the "action_summary" edge to the ActionSummary entity.
func (mu *MetricsUpdate) SetActionSummary(a *ActionSummary) *MetricsUpdate {
	return mu.SetActionSummaryID(a.ID)
}

// SetMemoryMetricsID sets the "memory_metrics" edge to the MemoryMetrics entity by ID.
func (mu *MetricsUpdate) SetMemoryMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetMemoryMetricsID(id)
	return mu
}

// SetNillableMemoryMetricsID sets the "memory_metrics" edge to the MemoryMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableMemoryMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetMemoryMetricsID(*id)
	}
	return mu
}

// SetMemoryMetrics sets the "memory_metrics" edge to the MemoryMetrics entity.
func (mu *MetricsUpdate) SetMemoryMetrics(m *MemoryMetrics) *MetricsUpdate {
	return mu.SetMemoryMetricsID(m.ID)
}

// SetTargetMetricsID sets the "target_metrics" edge to the TargetMetrics entity by ID.
func (mu *MetricsUpdate) SetTargetMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetTargetMetricsID(id)
	return mu
}

// SetNillableTargetMetricsID sets the "target_metrics" edge to the TargetMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableTargetMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetTargetMetricsID(*id)
	}
	return mu
}

// SetTargetMetrics sets the "target_metrics" edge to the TargetMetrics entity.
func (mu *MetricsUpdate) SetTargetMetrics(t *TargetMetrics) *MetricsUpdate {
	return mu.SetTargetMetricsID(t.ID)
}

// SetPackageMetricsID sets the "package_metrics" edge to the PackageMetrics entity by ID.
func (mu *MetricsUpdate) SetPackageMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetPackageMetricsID(id)
	return mu
}

// SetNillablePackageMetricsID sets the "package_metrics" edge to the PackageMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillablePackageMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetPackageMetricsID(*id)
	}
	return mu
}

// SetPackageMetrics sets the "package_metrics" edge to the PackageMetrics entity.
func (mu *MetricsUpdate) SetPackageMetrics(p *PackageMetrics) *MetricsUpdate {
	return mu.SetPackageMetricsID(p.ID)
}

// SetTimingMetricsID sets the "timing_metrics" edge to the TimingMetrics entity by ID.
func (mu *MetricsUpdate) SetTimingMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetTimingMetricsID(id)
	return mu
}

// SetNillableTimingMetricsID sets the "timing_metrics" edge to the TimingMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableTimingMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetTimingMetricsID(*id)
	}
	return mu
}

// SetTimingMetrics sets the "timing_metrics" edge to the TimingMetrics entity.
func (mu *MetricsUpdate) SetTimingMetrics(t *TimingMetrics) *MetricsUpdate {
	return mu.SetTimingMetricsID(t.ID)
}

// SetCumulativeMetricsID sets the "cumulative_metrics" edge to the CumulativeMetrics entity by ID.
func (mu *MetricsUpdate) SetCumulativeMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetCumulativeMetricsID(id)
	return mu
}

// SetNillableCumulativeMetricsID sets the "cumulative_metrics" edge to the CumulativeMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableCumulativeMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetCumulativeMetricsID(*id)
	}
	return mu
}

// SetCumulativeMetrics sets the "cumulative_metrics" edge to the CumulativeMetrics entity.
func (mu *MetricsUpdate) SetCumulativeMetrics(c *CumulativeMetrics) *MetricsUpdate {
	return mu.SetCumulativeMetricsID(c.ID)
}

// SetArtifactMetricsID sets the "artifact_metrics" edge to the ArtifactMetrics entity by ID.
func (mu *MetricsUpdate) SetArtifactMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetArtifactMetricsID(id)
	return mu
}

// SetNillableArtifactMetricsID sets the "artifact_metrics" edge to the ArtifactMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableArtifactMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetArtifactMetricsID(*id)
	}
	return mu
}

// SetArtifactMetrics sets the "artifact_metrics" edge to the ArtifactMetrics entity.
func (mu *MetricsUpdate) SetArtifactMetrics(a *ArtifactMetrics) *MetricsUpdate {
	return mu.SetArtifactMetricsID(a.ID)
}

// SetNetworkMetricsID sets the "network_metrics" edge to the NetworkMetrics entity by ID.
func (mu *MetricsUpdate) SetNetworkMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetNetworkMetricsID(id)
	return mu
}

// SetNillableNetworkMetricsID sets the "network_metrics" edge to the NetworkMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableNetworkMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetNetworkMetricsID(*id)
	}
	return mu
}

// SetNetworkMetrics sets the "network_metrics" edge to the NetworkMetrics entity.
func (mu *MetricsUpdate) SetNetworkMetrics(n *NetworkMetrics) *MetricsUpdate {
	return mu.SetNetworkMetricsID(n.ID)
}

// SetDynamicExecutionMetricsID sets the "dynamic_execution_metrics" edge to the DynamicExecutionMetrics entity by ID.
func (mu *MetricsUpdate) SetDynamicExecutionMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetDynamicExecutionMetricsID(id)
	return mu
}

// SetNillableDynamicExecutionMetricsID sets the "dynamic_execution_metrics" edge to the DynamicExecutionMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableDynamicExecutionMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetDynamicExecutionMetricsID(*id)
	}
	return mu
}

// SetDynamicExecutionMetrics sets the "dynamic_execution_metrics" edge to the DynamicExecutionMetrics entity.
func (mu *MetricsUpdate) SetDynamicExecutionMetrics(d *DynamicExecutionMetrics) *MetricsUpdate {
	return mu.SetDynamicExecutionMetricsID(d.ID)
}

// SetBuildGraphMetricsID sets the "build_graph_metrics" edge to the BuildGraphMetrics entity by ID.
func (mu *MetricsUpdate) SetBuildGraphMetricsID(id int) *MetricsUpdate {
	mu.mutation.SetBuildGraphMetricsID(id)
	return mu
}

// SetNillableBuildGraphMetricsID sets the "build_graph_metrics" edge to the BuildGraphMetrics entity by ID if the given value is not nil.
func (mu *MetricsUpdate) SetNillableBuildGraphMetricsID(id *int) *MetricsUpdate {
	if id != nil {
		mu = mu.SetBuildGraphMetricsID(*id)
	}
	return mu
}

// SetBuildGraphMetrics sets the "build_graph_metrics" edge to the BuildGraphMetrics entity.
func (mu *MetricsUpdate) SetBuildGraphMetrics(b *BuildGraphMetrics) *MetricsUpdate {
	return mu.SetBuildGraphMetricsID(b.ID)
}

// Mutation returns the MetricsMutation object of the builder.
func (mu *MetricsUpdate) Mutation() *MetricsMutation {
	return mu.mutation
}

// ClearBazelInvocation clears the "bazel_invocation" edge to the BazelInvocation entity.
func (mu *MetricsUpdate) ClearBazelInvocation() *MetricsUpdate {
	mu.mutation.ClearBazelInvocation()
	return mu
}

// ClearActionSummary clears the "action_summary" edge to the ActionSummary entity.
func (mu *MetricsUpdate) ClearActionSummary() *MetricsUpdate {
	mu.mutation.ClearActionSummary()
	return mu
}

// ClearMemoryMetrics clears the "memory_metrics" edge to the MemoryMetrics entity.
func (mu *MetricsUpdate) ClearMemoryMetrics() *MetricsUpdate {
	mu.mutation.ClearMemoryMetrics()
	return mu
}

// ClearTargetMetrics clears the "target_metrics" edge to the TargetMetrics entity.
func (mu *MetricsUpdate) ClearTargetMetrics() *MetricsUpdate {
	mu.mutation.ClearTargetMetrics()
	return mu
}

// ClearPackageMetrics clears the "package_metrics" edge to the PackageMetrics entity.
func (mu *MetricsUpdate) ClearPackageMetrics() *MetricsUpdate {
	mu.mutation.ClearPackageMetrics()
	return mu
}

// ClearTimingMetrics clears the "timing_metrics" edge to the TimingMetrics entity.
func (mu *MetricsUpdate) ClearTimingMetrics() *MetricsUpdate {
	mu.mutation.ClearTimingMetrics()
	return mu
}

// ClearCumulativeMetrics clears the "cumulative_metrics" edge to the CumulativeMetrics entity.
func (mu *MetricsUpdate) ClearCumulativeMetrics() *MetricsUpdate {
	mu.mutation.ClearCumulativeMetrics()
	return mu
}

// ClearArtifactMetrics clears the "artifact_metrics" edge to the ArtifactMetrics entity.
func (mu *MetricsUpdate) ClearArtifactMetrics() *MetricsUpdate {
	mu.mutation.ClearArtifactMetrics()
	return mu
}

// ClearNetworkMetrics clears the "network_metrics" edge to the NetworkMetrics entity.
func (mu *MetricsUpdate) ClearNetworkMetrics() *MetricsUpdate {
	mu.mutation.ClearNetworkMetrics()
	return mu
}

// ClearDynamicExecutionMetrics clears the "dynamic_execution_metrics" edge to the DynamicExecutionMetrics entity.
func (mu *MetricsUpdate) ClearDynamicExecutionMetrics() *MetricsUpdate {
	mu.mutation.ClearDynamicExecutionMetrics()
	return mu
}

// ClearBuildGraphMetrics clears the "build_graph_metrics" edge to the BuildGraphMetrics entity.
func (mu *MetricsUpdate) ClearBuildGraphMetrics() *MetricsUpdate {
	mu.mutation.ClearBuildGraphMetrics()
	return mu
}

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

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

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

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

func (mu *MetricsUpdate) sqlSave(ctx context.Context) (n int, err error) {
	_spec := sqlgraph.NewUpdateSpec(metrics.Table, metrics.Columns, sqlgraph.NewFieldSpec(metrics.FieldID, field.TypeInt))
	if ps := mu.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if mu.mutation.BazelInvocationCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   metrics.BazelInvocationTable,
			Columns: []string{metrics.BazelInvocationColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(bazelinvocation.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.BazelInvocationIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   metrics.BazelInvocationTable,
			Columns: []string{metrics.BazelInvocationColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(bazelinvocation.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.ActionSummaryCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.ActionSummaryTable,
			Columns: []string{metrics.ActionSummaryColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(actionsummary.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.ActionSummaryIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.ActionSummaryTable,
			Columns: []string{metrics.ActionSummaryColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(actionsummary.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.MemoryMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.MemoryMetricsTable,
			Columns: []string{metrics.MemoryMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(memorymetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.MemoryMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.MemoryMetricsTable,
			Columns: []string{metrics.MemoryMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(memorymetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.TargetMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.TargetMetricsTable,
			Columns: []string{metrics.TargetMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(targetmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.TargetMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.TargetMetricsTable,
			Columns: []string{metrics.TargetMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(targetmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.PackageMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.PackageMetricsTable,
			Columns: []string{metrics.PackageMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(packagemetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.PackageMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.PackageMetricsTable,
			Columns: []string{metrics.PackageMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(packagemetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.TimingMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.TimingMetricsTable,
			Columns: []string{metrics.TimingMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(timingmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.TimingMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.TimingMetricsTable,
			Columns: []string{metrics.TimingMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(timingmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.CumulativeMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.CumulativeMetricsTable,
			Columns: []string{metrics.CumulativeMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(cumulativemetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.CumulativeMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.CumulativeMetricsTable,
			Columns: []string{metrics.CumulativeMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(cumulativemetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.ArtifactMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.ArtifactMetricsTable,
			Columns: []string{metrics.ArtifactMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(artifactmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.ArtifactMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.ArtifactMetricsTable,
			Columns: []string{metrics.ArtifactMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(artifactmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.NetworkMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.NetworkMetricsTable,
			Columns: []string{metrics.NetworkMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(networkmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.NetworkMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.NetworkMetricsTable,
			Columns: []string{metrics.NetworkMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(networkmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.DynamicExecutionMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.DynamicExecutionMetricsTable,
			Columns: []string{metrics.DynamicExecutionMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(dynamicexecutionmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.DynamicExecutionMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.DynamicExecutionMetricsTable,
			Columns: []string{metrics.DynamicExecutionMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(dynamicexecutionmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if mu.mutation.BuildGraphMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.BuildGraphMetricsTable,
			Columns: []string{metrics.BuildGraphMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(buildgraphmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := mu.mutation.BuildGraphMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.BuildGraphMetricsTable,
			Columns: []string{metrics.BuildGraphMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(buildgraphmetrics.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, mu.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{metrics.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	mu.mutation.done = true
	return n, nil
}

// MetricsUpdateOne is the builder for updating a single Metrics entity.
type MetricsUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *MetricsMutation
}

// SetBazelInvocationID sets the "bazel_invocation" edge to the BazelInvocation entity by ID.
func (muo *MetricsUpdateOne) SetBazelInvocationID(id int) *MetricsUpdateOne {
	muo.mutation.SetBazelInvocationID(id)
	return muo
}

// SetNillableBazelInvocationID sets the "bazel_invocation" edge to the BazelInvocation entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableBazelInvocationID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetBazelInvocationID(*id)
	}
	return muo
}

// SetBazelInvocation sets the "bazel_invocation" edge to the BazelInvocation entity.
func (muo *MetricsUpdateOne) SetBazelInvocation(b *BazelInvocation) *MetricsUpdateOne {
	return muo.SetBazelInvocationID(b.ID)
}

// SetActionSummaryID sets the "action_summary" edge to the ActionSummary entity by ID.
func (muo *MetricsUpdateOne) SetActionSummaryID(id int) *MetricsUpdateOne {
	muo.mutation.SetActionSummaryID(id)
	return muo
}

// SetNillableActionSummaryID sets the "action_summary" edge to the ActionSummary entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableActionSummaryID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetActionSummaryID(*id)
	}
	return muo
}

// SetActionSummary sets the "action_summary" edge to the ActionSummary entity.
func (muo *MetricsUpdateOne) SetActionSummary(a *ActionSummary) *MetricsUpdateOne {
	return muo.SetActionSummaryID(a.ID)
}

// SetMemoryMetricsID sets the "memory_metrics" edge to the MemoryMetrics entity by ID.
func (muo *MetricsUpdateOne) SetMemoryMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetMemoryMetricsID(id)
	return muo
}

// SetNillableMemoryMetricsID sets the "memory_metrics" edge to the MemoryMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableMemoryMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetMemoryMetricsID(*id)
	}
	return muo
}

// SetMemoryMetrics sets the "memory_metrics" edge to the MemoryMetrics entity.
func (muo *MetricsUpdateOne) SetMemoryMetrics(m *MemoryMetrics) *MetricsUpdateOne {
	return muo.SetMemoryMetricsID(m.ID)
}

// SetTargetMetricsID sets the "target_metrics" edge to the TargetMetrics entity by ID.
func (muo *MetricsUpdateOne) SetTargetMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetTargetMetricsID(id)
	return muo
}

// SetNillableTargetMetricsID sets the "target_metrics" edge to the TargetMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableTargetMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetTargetMetricsID(*id)
	}
	return muo
}

// SetTargetMetrics sets the "target_metrics" edge to the TargetMetrics entity.
func (muo *MetricsUpdateOne) SetTargetMetrics(t *TargetMetrics) *MetricsUpdateOne {
	return muo.SetTargetMetricsID(t.ID)
}

// SetPackageMetricsID sets the "package_metrics" edge to the PackageMetrics entity by ID.
func (muo *MetricsUpdateOne) SetPackageMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetPackageMetricsID(id)
	return muo
}

// SetNillablePackageMetricsID sets the "package_metrics" edge to the PackageMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillablePackageMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetPackageMetricsID(*id)
	}
	return muo
}

// SetPackageMetrics sets the "package_metrics" edge to the PackageMetrics entity.
func (muo *MetricsUpdateOne) SetPackageMetrics(p *PackageMetrics) *MetricsUpdateOne {
	return muo.SetPackageMetricsID(p.ID)
}

// SetTimingMetricsID sets the "timing_metrics" edge to the TimingMetrics entity by ID.
func (muo *MetricsUpdateOne) SetTimingMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetTimingMetricsID(id)
	return muo
}

// SetNillableTimingMetricsID sets the "timing_metrics" edge to the TimingMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableTimingMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetTimingMetricsID(*id)
	}
	return muo
}

// SetTimingMetrics sets the "timing_metrics" edge to the TimingMetrics entity.
func (muo *MetricsUpdateOne) SetTimingMetrics(t *TimingMetrics) *MetricsUpdateOne {
	return muo.SetTimingMetricsID(t.ID)
}

// SetCumulativeMetricsID sets the "cumulative_metrics" edge to the CumulativeMetrics entity by ID.
func (muo *MetricsUpdateOne) SetCumulativeMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetCumulativeMetricsID(id)
	return muo
}

// SetNillableCumulativeMetricsID sets the "cumulative_metrics" edge to the CumulativeMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableCumulativeMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetCumulativeMetricsID(*id)
	}
	return muo
}

// SetCumulativeMetrics sets the "cumulative_metrics" edge to the CumulativeMetrics entity.
func (muo *MetricsUpdateOne) SetCumulativeMetrics(c *CumulativeMetrics) *MetricsUpdateOne {
	return muo.SetCumulativeMetricsID(c.ID)
}

// SetArtifactMetricsID sets the "artifact_metrics" edge to the ArtifactMetrics entity by ID.
func (muo *MetricsUpdateOne) SetArtifactMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetArtifactMetricsID(id)
	return muo
}

// SetNillableArtifactMetricsID sets the "artifact_metrics" edge to the ArtifactMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableArtifactMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetArtifactMetricsID(*id)
	}
	return muo
}

// SetArtifactMetrics sets the "artifact_metrics" edge to the ArtifactMetrics entity.
func (muo *MetricsUpdateOne) SetArtifactMetrics(a *ArtifactMetrics) *MetricsUpdateOne {
	return muo.SetArtifactMetricsID(a.ID)
}

// SetNetworkMetricsID sets the "network_metrics" edge to the NetworkMetrics entity by ID.
func (muo *MetricsUpdateOne) SetNetworkMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetNetworkMetricsID(id)
	return muo
}

// SetNillableNetworkMetricsID sets the "network_metrics" edge to the NetworkMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableNetworkMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetNetworkMetricsID(*id)
	}
	return muo
}

// SetNetworkMetrics sets the "network_metrics" edge to the NetworkMetrics entity.
func (muo *MetricsUpdateOne) SetNetworkMetrics(n *NetworkMetrics) *MetricsUpdateOne {
	return muo.SetNetworkMetricsID(n.ID)
}

// SetDynamicExecutionMetricsID sets the "dynamic_execution_metrics" edge to the DynamicExecutionMetrics entity by ID.
func (muo *MetricsUpdateOne) SetDynamicExecutionMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetDynamicExecutionMetricsID(id)
	return muo
}

// SetNillableDynamicExecutionMetricsID sets the "dynamic_execution_metrics" edge to the DynamicExecutionMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableDynamicExecutionMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetDynamicExecutionMetricsID(*id)
	}
	return muo
}

// SetDynamicExecutionMetrics sets the "dynamic_execution_metrics" edge to the DynamicExecutionMetrics entity.
func (muo *MetricsUpdateOne) SetDynamicExecutionMetrics(d *DynamicExecutionMetrics) *MetricsUpdateOne {
	return muo.SetDynamicExecutionMetricsID(d.ID)
}

// SetBuildGraphMetricsID sets the "build_graph_metrics" edge to the BuildGraphMetrics entity by ID.
func (muo *MetricsUpdateOne) SetBuildGraphMetricsID(id int) *MetricsUpdateOne {
	muo.mutation.SetBuildGraphMetricsID(id)
	return muo
}

// SetNillableBuildGraphMetricsID sets the "build_graph_metrics" edge to the BuildGraphMetrics entity by ID if the given value is not nil.
func (muo *MetricsUpdateOne) SetNillableBuildGraphMetricsID(id *int) *MetricsUpdateOne {
	if id != nil {
		muo = muo.SetBuildGraphMetricsID(*id)
	}
	return muo
}

// SetBuildGraphMetrics sets the "build_graph_metrics" edge to the BuildGraphMetrics entity.
func (muo *MetricsUpdateOne) SetBuildGraphMetrics(b *BuildGraphMetrics) *MetricsUpdateOne {
	return muo.SetBuildGraphMetricsID(b.ID)
}

// Mutation returns the MetricsMutation object of the builder.
func (muo *MetricsUpdateOne) Mutation() *MetricsMutation {
	return muo.mutation
}

// ClearBazelInvocation clears the "bazel_invocation" edge to the BazelInvocation entity.
func (muo *MetricsUpdateOne) ClearBazelInvocation() *MetricsUpdateOne {
	muo.mutation.ClearBazelInvocation()
	return muo
}

// ClearActionSummary clears the "action_summary" edge to the ActionSummary entity.
func (muo *MetricsUpdateOne) ClearActionSummary() *MetricsUpdateOne {
	muo.mutation.ClearActionSummary()
	return muo
}

// ClearMemoryMetrics clears the "memory_metrics" edge to the MemoryMetrics entity.
func (muo *MetricsUpdateOne) ClearMemoryMetrics() *MetricsUpdateOne {
	muo.mutation.ClearMemoryMetrics()
	return muo
}

// ClearTargetMetrics clears the "target_metrics" edge to the TargetMetrics entity.
func (muo *MetricsUpdateOne) ClearTargetMetrics() *MetricsUpdateOne {
	muo.mutation.ClearTargetMetrics()
	return muo
}

// ClearPackageMetrics clears the "package_metrics" edge to the PackageMetrics entity.
func (muo *MetricsUpdateOne) ClearPackageMetrics() *MetricsUpdateOne {
	muo.mutation.ClearPackageMetrics()
	return muo
}

// ClearTimingMetrics clears the "timing_metrics" edge to the TimingMetrics entity.
func (muo *MetricsUpdateOne) ClearTimingMetrics() *MetricsUpdateOne {
	muo.mutation.ClearTimingMetrics()
	return muo
}

// ClearCumulativeMetrics clears the "cumulative_metrics" edge to the CumulativeMetrics entity.
func (muo *MetricsUpdateOne) ClearCumulativeMetrics() *MetricsUpdateOne {
	muo.mutation.ClearCumulativeMetrics()
	return muo
}

// ClearArtifactMetrics clears the "artifact_metrics" edge to the ArtifactMetrics entity.
func (muo *MetricsUpdateOne) ClearArtifactMetrics() *MetricsUpdateOne {
	muo.mutation.ClearArtifactMetrics()
	return muo
}

// ClearNetworkMetrics clears the "network_metrics" edge to the NetworkMetrics entity.
func (muo *MetricsUpdateOne) ClearNetworkMetrics() *MetricsUpdateOne {
	muo.mutation.ClearNetworkMetrics()
	return muo
}

// ClearDynamicExecutionMetrics clears the "dynamic_execution_metrics" edge to the DynamicExecutionMetrics entity.
func (muo *MetricsUpdateOne) ClearDynamicExecutionMetrics() *MetricsUpdateOne {
	muo.mutation.ClearDynamicExecutionMetrics()
	return muo
}

// ClearBuildGraphMetrics clears the "build_graph_metrics" edge to the BuildGraphMetrics entity.
func (muo *MetricsUpdateOne) ClearBuildGraphMetrics() *MetricsUpdateOne {
	muo.mutation.ClearBuildGraphMetrics()
	return muo
}

// Where appends a list predicates to the MetricsUpdate builder.
func (muo *MetricsUpdateOne) Where(ps ...predicate.Metrics) *MetricsUpdateOne {
	muo.mutation.Where(ps...)
	return muo
}

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

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

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

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

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

func (muo *MetricsUpdateOne) sqlSave(ctx context.Context) (_node *Metrics, err error) {
	_spec := sqlgraph.NewUpdateSpec(metrics.Table, metrics.Columns, sqlgraph.NewFieldSpec(metrics.FieldID, field.TypeInt))
	id, ok := muo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Metrics.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := muo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, metrics.FieldID)
		for _, f := range fields {
			if !metrics.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != metrics.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := muo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if muo.mutation.BazelInvocationCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   metrics.BazelInvocationTable,
			Columns: []string{metrics.BazelInvocationColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(bazelinvocation.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.BazelInvocationIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   metrics.BazelInvocationTable,
			Columns: []string{metrics.BazelInvocationColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(bazelinvocation.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.ActionSummaryCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.ActionSummaryTable,
			Columns: []string{metrics.ActionSummaryColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(actionsummary.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.ActionSummaryIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.ActionSummaryTable,
			Columns: []string{metrics.ActionSummaryColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(actionsummary.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.MemoryMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.MemoryMetricsTable,
			Columns: []string{metrics.MemoryMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(memorymetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.MemoryMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.MemoryMetricsTable,
			Columns: []string{metrics.MemoryMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(memorymetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.TargetMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.TargetMetricsTable,
			Columns: []string{metrics.TargetMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(targetmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.TargetMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.TargetMetricsTable,
			Columns: []string{metrics.TargetMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(targetmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.PackageMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.PackageMetricsTable,
			Columns: []string{metrics.PackageMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(packagemetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.PackageMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.PackageMetricsTable,
			Columns: []string{metrics.PackageMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(packagemetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.TimingMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.TimingMetricsTable,
			Columns: []string{metrics.TimingMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(timingmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.TimingMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.TimingMetricsTable,
			Columns: []string{metrics.TimingMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(timingmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.CumulativeMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.CumulativeMetricsTable,
			Columns: []string{metrics.CumulativeMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(cumulativemetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.CumulativeMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.CumulativeMetricsTable,
			Columns: []string{metrics.CumulativeMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(cumulativemetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.ArtifactMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.ArtifactMetricsTable,
			Columns: []string{metrics.ArtifactMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(artifactmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.ArtifactMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.ArtifactMetricsTable,
			Columns: []string{metrics.ArtifactMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(artifactmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.NetworkMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.NetworkMetricsTable,
			Columns: []string{metrics.NetworkMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(networkmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.NetworkMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.NetworkMetricsTable,
			Columns: []string{metrics.NetworkMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(networkmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.DynamicExecutionMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.DynamicExecutionMetricsTable,
			Columns: []string{metrics.DynamicExecutionMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(dynamicexecutionmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.DynamicExecutionMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.DynamicExecutionMetricsTable,
			Columns: []string{metrics.DynamicExecutionMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(dynamicexecutionmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if muo.mutation.BuildGraphMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.BuildGraphMetricsTable,
			Columns: []string{metrics.BuildGraphMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(buildgraphmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := muo.mutation.BuildGraphMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: false,
			Table:   metrics.BuildGraphMetricsTable,
			Columns: []string{metrics.BuildGraphMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(buildgraphmetrics.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_node = &Metrics{config: muo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{metrics.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	muo.mutation.done = true
	return _node, nil
}
