// 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/dynamicexecutionmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/predicate"
	"github.com/buildbarn/bb-portal/ent/gen/ent/racestatistics"
)

// RaceStatisticsUpdate is the builder for updating RaceStatistics entities.
type RaceStatisticsUpdate struct {
	config
	hooks    []Hook
	mutation *RaceStatisticsMutation
}

// Where appends a list predicates to the RaceStatisticsUpdate builder.
func (rsu *RaceStatisticsUpdate) Where(ps ...predicate.RaceStatistics) *RaceStatisticsUpdate {
	rsu.mutation.Where(ps...)
	return rsu
}

// SetMnemonic sets the "mnemonic" field.
func (rsu *RaceStatisticsUpdate) SetMnemonic(s string) *RaceStatisticsUpdate {
	rsu.mutation.SetMnemonic(s)
	return rsu
}

// SetNillableMnemonic sets the "mnemonic" field if the given value is not nil.
func (rsu *RaceStatisticsUpdate) SetNillableMnemonic(s *string) *RaceStatisticsUpdate {
	if s != nil {
		rsu.SetMnemonic(*s)
	}
	return rsu
}

// ClearMnemonic clears the value of the "mnemonic" field.
func (rsu *RaceStatisticsUpdate) ClearMnemonic() *RaceStatisticsUpdate {
	rsu.mutation.ClearMnemonic()
	return rsu
}

// SetLocalRunner sets the "local_runner" field.
func (rsu *RaceStatisticsUpdate) SetLocalRunner(s string) *RaceStatisticsUpdate {
	rsu.mutation.SetLocalRunner(s)
	return rsu
}

// SetNillableLocalRunner sets the "local_runner" field if the given value is not nil.
func (rsu *RaceStatisticsUpdate) SetNillableLocalRunner(s *string) *RaceStatisticsUpdate {
	if s != nil {
		rsu.SetLocalRunner(*s)
	}
	return rsu
}

// ClearLocalRunner clears the value of the "local_runner" field.
func (rsu *RaceStatisticsUpdate) ClearLocalRunner() *RaceStatisticsUpdate {
	rsu.mutation.ClearLocalRunner()
	return rsu
}

// SetRemoteRunner sets the "remote_runner" field.
func (rsu *RaceStatisticsUpdate) SetRemoteRunner(s string) *RaceStatisticsUpdate {
	rsu.mutation.SetRemoteRunner(s)
	return rsu
}

// SetNillableRemoteRunner sets the "remote_runner" field if the given value is not nil.
func (rsu *RaceStatisticsUpdate) SetNillableRemoteRunner(s *string) *RaceStatisticsUpdate {
	if s != nil {
		rsu.SetRemoteRunner(*s)
	}
	return rsu
}

// ClearRemoteRunner clears the value of the "remote_runner" field.
func (rsu *RaceStatisticsUpdate) ClearRemoteRunner() *RaceStatisticsUpdate {
	rsu.mutation.ClearRemoteRunner()
	return rsu
}

// SetLocalWins sets the "local_wins" field.
func (rsu *RaceStatisticsUpdate) SetLocalWins(i int64) *RaceStatisticsUpdate {
	rsu.mutation.ResetLocalWins()
	rsu.mutation.SetLocalWins(i)
	return rsu
}

// SetNillableLocalWins sets the "local_wins" field if the given value is not nil.
func (rsu *RaceStatisticsUpdate) SetNillableLocalWins(i *int64) *RaceStatisticsUpdate {
	if i != nil {
		rsu.SetLocalWins(*i)
	}
	return rsu
}

// AddLocalWins adds i to the "local_wins" field.
func (rsu *RaceStatisticsUpdate) AddLocalWins(i int64) *RaceStatisticsUpdate {
	rsu.mutation.AddLocalWins(i)
	return rsu
}

// ClearLocalWins clears the value of the "local_wins" field.
func (rsu *RaceStatisticsUpdate) ClearLocalWins() *RaceStatisticsUpdate {
	rsu.mutation.ClearLocalWins()
	return rsu
}

// SetRenoteWins sets the "renote_wins" field.
func (rsu *RaceStatisticsUpdate) SetRenoteWins(i int64) *RaceStatisticsUpdate {
	rsu.mutation.ResetRenoteWins()
	rsu.mutation.SetRenoteWins(i)
	return rsu
}

// SetNillableRenoteWins sets the "renote_wins" field if the given value is not nil.
func (rsu *RaceStatisticsUpdate) SetNillableRenoteWins(i *int64) *RaceStatisticsUpdate {
	if i != nil {
		rsu.SetRenoteWins(*i)
	}
	return rsu
}

// AddRenoteWins adds i to the "renote_wins" field.
func (rsu *RaceStatisticsUpdate) AddRenoteWins(i int64) *RaceStatisticsUpdate {
	rsu.mutation.AddRenoteWins(i)
	return rsu
}

// ClearRenoteWins clears the value of the "renote_wins" field.
func (rsu *RaceStatisticsUpdate) ClearRenoteWins() *RaceStatisticsUpdate {
	rsu.mutation.ClearRenoteWins()
	return rsu
}

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

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

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

// Mutation returns the RaceStatisticsMutation object of the builder.
func (rsu *RaceStatisticsUpdate) Mutation() *RaceStatisticsMutation {
	return rsu.mutation
}

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

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

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

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

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

func (rsu *RaceStatisticsUpdate) sqlSave(ctx context.Context) (n int, err error) {
	_spec := sqlgraph.NewUpdateSpec(racestatistics.Table, racestatistics.Columns, sqlgraph.NewFieldSpec(racestatistics.FieldID, field.TypeInt))
	if ps := rsu.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := rsu.mutation.Mnemonic(); ok {
		_spec.SetField(racestatistics.FieldMnemonic, field.TypeString, value)
	}
	if rsu.mutation.MnemonicCleared() {
		_spec.ClearField(racestatistics.FieldMnemonic, field.TypeString)
	}
	if value, ok := rsu.mutation.LocalRunner(); ok {
		_spec.SetField(racestatistics.FieldLocalRunner, field.TypeString, value)
	}
	if rsu.mutation.LocalRunnerCleared() {
		_spec.ClearField(racestatistics.FieldLocalRunner, field.TypeString)
	}
	if value, ok := rsu.mutation.RemoteRunner(); ok {
		_spec.SetField(racestatistics.FieldRemoteRunner, field.TypeString, value)
	}
	if rsu.mutation.RemoteRunnerCleared() {
		_spec.ClearField(racestatistics.FieldRemoteRunner, field.TypeString)
	}
	if value, ok := rsu.mutation.LocalWins(); ok {
		_spec.SetField(racestatistics.FieldLocalWins, field.TypeInt64, value)
	}
	if value, ok := rsu.mutation.AddedLocalWins(); ok {
		_spec.AddField(racestatistics.FieldLocalWins, field.TypeInt64, value)
	}
	if rsu.mutation.LocalWinsCleared() {
		_spec.ClearField(racestatistics.FieldLocalWins, field.TypeInt64)
	}
	if value, ok := rsu.mutation.RenoteWins(); ok {
		_spec.SetField(racestatistics.FieldRenoteWins, field.TypeInt64, value)
	}
	if value, ok := rsu.mutation.AddedRenoteWins(); ok {
		_spec.AddField(racestatistics.FieldRenoteWins, field.TypeInt64, value)
	}
	if rsu.mutation.RenoteWinsCleared() {
		_spec.ClearField(racestatistics.FieldRenoteWins, field.TypeInt64)
	}
	if rsu.mutation.DynamicExecutionMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   racestatistics.DynamicExecutionMetricsTable,
			Columns: []string{racestatistics.DynamicExecutionMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(dynamicexecutionmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := rsu.mutation.DynamicExecutionMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   racestatistics.DynamicExecutionMetricsTable,
			Columns: []string{racestatistics.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 n, err = sqlgraph.UpdateNodes(ctx, rsu.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{racestatistics.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	rsu.mutation.done = true
	return n, nil
}

// RaceStatisticsUpdateOne is the builder for updating a single RaceStatistics entity.
type RaceStatisticsUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *RaceStatisticsMutation
}

// SetMnemonic sets the "mnemonic" field.
func (rsuo *RaceStatisticsUpdateOne) SetMnemonic(s string) *RaceStatisticsUpdateOne {
	rsuo.mutation.SetMnemonic(s)
	return rsuo
}

// SetNillableMnemonic sets the "mnemonic" field if the given value is not nil.
func (rsuo *RaceStatisticsUpdateOne) SetNillableMnemonic(s *string) *RaceStatisticsUpdateOne {
	if s != nil {
		rsuo.SetMnemonic(*s)
	}
	return rsuo
}

// ClearMnemonic clears the value of the "mnemonic" field.
func (rsuo *RaceStatisticsUpdateOne) ClearMnemonic() *RaceStatisticsUpdateOne {
	rsuo.mutation.ClearMnemonic()
	return rsuo
}

// SetLocalRunner sets the "local_runner" field.
func (rsuo *RaceStatisticsUpdateOne) SetLocalRunner(s string) *RaceStatisticsUpdateOne {
	rsuo.mutation.SetLocalRunner(s)
	return rsuo
}

// SetNillableLocalRunner sets the "local_runner" field if the given value is not nil.
func (rsuo *RaceStatisticsUpdateOne) SetNillableLocalRunner(s *string) *RaceStatisticsUpdateOne {
	if s != nil {
		rsuo.SetLocalRunner(*s)
	}
	return rsuo
}

// ClearLocalRunner clears the value of the "local_runner" field.
func (rsuo *RaceStatisticsUpdateOne) ClearLocalRunner() *RaceStatisticsUpdateOne {
	rsuo.mutation.ClearLocalRunner()
	return rsuo
}

// SetRemoteRunner sets the "remote_runner" field.
func (rsuo *RaceStatisticsUpdateOne) SetRemoteRunner(s string) *RaceStatisticsUpdateOne {
	rsuo.mutation.SetRemoteRunner(s)
	return rsuo
}

// SetNillableRemoteRunner sets the "remote_runner" field if the given value is not nil.
func (rsuo *RaceStatisticsUpdateOne) SetNillableRemoteRunner(s *string) *RaceStatisticsUpdateOne {
	if s != nil {
		rsuo.SetRemoteRunner(*s)
	}
	return rsuo
}

// ClearRemoteRunner clears the value of the "remote_runner" field.
func (rsuo *RaceStatisticsUpdateOne) ClearRemoteRunner() *RaceStatisticsUpdateOne {
	rsuo.mutation.ClearRemoteRunner()
	return rsuo
}

// SetLocalWins sets the "local_wins" field.
func (rsuo *RaceStatisticsUpdateOne) SetLocalWins(i int64) *RaceStatisticsUpdateOne {
	rsuo.mutation.ResetLocalWins()
	rsuo.mutation.SetLocalWins(i)
	return rsuo
}

// SetNillableLocalWins sets the "local_wins" field if the given value is not nil.
func (rsuo *RaceStatisticsUpdateOne) SetNillableLocalWins(i *int64) *RaceStatisticsUpdateOne {
	if i != nil {
		rsuo.SetLocalWins(*i)
	}
	return rsuo
}

// AddLocalWins adds i to the "local_wins" field.
func (rsuo *RaceStatisticsUpdateOne) AddLocalWins(i int64) *RaceStatisticsUpdateOne {
	rsuo.mutation.AddLocalWins(i)
	return rsuo
}

// ClearLocalWins clears the value of the "local_wins" field.
func (rsuo *RaceStatisticsUpdateOne) ClearLocalWins() *RaceStatisticsUpdateOne {
	rsuo.mutation.ClearLocalWins()
	return rsuo
}

// SetRenoteWins sets the "renote_wins" field.
func (rsuo *RaceStatisticsUpdateOne) SetRenoteWins(i int64) *RaceStatisticsUpdateOne {
	rsuo.mutation.ResetRenoteWins()
	rsuo.mutation.SetRenoteWins(i)
	return rsuo
}

// SetNillableRenoteWins sets the "renote_wins" field if the given value is not nil.
func (rsuo *RaceStatisticsUpdateOne) SetNillableRenoteWins(i *int64) *RaceStatisticsUpdateOne {
	if i != nil {
		rsuo.SetRenoteWins(*i)
	}
	return rsuo
}

// AddRenoteWins adds i to the "renote_wins" field.
func (rsuo *RaceStatisticsUpdateOne) AddRenoteWins(i int64) *RaceStatisticsUpdateOne {
	rsuo.mutation.AddRenoteWins(i)
	return rsuo
}

// ClearRenoteWins clears the value of the "renote_wins" field.
func (rsuo *RaceStatisticsUpdateOne) ClearRenoteWins() *RaceStatisticsUpdateOne {
	rsuo.mutation.ClearRenoteWins()
	return rsuo
}

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

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

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

// Mutation returns the RaceStatisticsMutation object of the builder.
func (rsuo *RaceStatisticsUpdateOne) Mutation() *RaceStatisticsMutation {
	return rsuo.mutation
}

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

// Where appends a list predicates to the RaceStatisticsUpdate builder.
func (rsuo *RaceStatisticsUpdateOne) Where(ps ...predicate.RaceStatistics) *RaceStatisticsUpdateOne {
	rsuo.mutation.Where(ps...)
	return rsuo
}

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

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

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

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

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

func (rsuo *RaceStatisticsUpdateOne) sqlSave(ctx context.Context) (_node *RaceStatistics, err error) {
	_spec := sqlgraph.NewUpdateSpec(racestatistics.Table, racestatistics.Columns, sqlgraph.NewFieldSpec(racestatistics.FieldID, field.TypeInt))
	id, ok := rsuo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RaceStatistics.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := rsuo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, racestatistics.FieldID)
		for _, f := range fields {
			if !racestatistics.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != racestatistics.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := rsuo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := rsuo.mutation.Mnemonic(); ok {
		_spec.SetField(racestatistics.FieldMnemonic, field.TypeString, value)
	}
	if rsuo.mutation.MnemonicCleared() {
		_spec.ClearField(racestatistics.FieldMnemonic, field.TypeString)
	}
	if value, ok := rsuo.mutation.LocalRunner(); ok {
		_spec.SetField(racestatistics.FieldLocalRunner, field.TypeString, value)
	}
	if rsuo.mutation.LocalRunnerCleared() {
		_spec.ClearField(racestatistics.FieldLocalRunner, field.TypeString)
	}
	if value, ok := rsuo.mutation.RemoteRunner(); ok {
		_spec.SetField(racestatistics.FieldRemoteRunner, field.TypeString, value)
	}
	if rsuo.mutation.RemoteRunnerCleared() {
		_spec.ClearField(racestatistics.FieldRemoteRunner, field.TypeString)
	}
	if value, ok := rsuo.mutation.LocalWins(); ok {
		_spec.SetField(racestatistics.FieldLocalWins, field.TypeInt64, value)
	}
	if value, ok := rsuo.mutation.AddedLocalWins(); ok {
		_spec.AddField(racestatistics.FieldLocalWins, field.TypeInt64, value)
	}
	if rsuo.mutation.LocalWinsCleared() {
		_spec.ClearField(racestatistics.FieldLocalWins, field.TypeInt64)
	}
	if value, ok := rsuo.mutation.RenoteWins(); ok {
		_spec.SetField(racestatistics.FieldRenoteWins, field.TypeInt64, value)
	}
	if value, ok := rsuo.mutation.AddedRenoteWins(); ok {
		_spec.AddField(racestatistics.FieldRenoteWins, field.TypeInt64, value)
	}
	if rsuo.mutation.RenoteWinsCleared() {
		_spec.ClearField(racestatistics.FieldRenoteWins, field.TypeInt64)
	}
	if rsuo.mutation.DynamicExecutionMetricsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   racestatistics.DynamicExecutionMetricsTable,
			Columns: []string{racestatistics.DynamicExecutionMetricsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(dynamicexecutionmetrics.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := rsuo.mutation.DynamicExecutionMetricsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   racestatistics.DynamicExecutionMetricsTable,
			Columns: []string{racestatistics.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)
	}
	_node = &RaceStatistics{config: rsuo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, rsuo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{racestatistics.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	rsuo.mutation.done = true
	return _node, nil
}
