// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"galileo/ent/predicate"
	"galileo/ent/testcase"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)

// TestcaseUpdate is the builder for updating Testcase entities.
type TestcaseUpdate struct {
	config
	hooks    []Hook
	mutation *TestcaseMutation
}

// Where appends a list predicates to the TestcaseUpdate builder.
func (tu *TestcaseUpdate) Where(ps ...predicate.Testcase) *TestcaseUpdate {
	tu.mutation.Where(ps...)
	return tu
}

// SetName sets the "name" field.
func (tu *TestcaseUpdate) SetName(s string) *TestcaseUpdate {
	tu.mutation.SetName(s)
	return tu
}

// SetUpdatedBy sets the "updated_by" field.
func (tu *TestcaseUpdate) SetUpdatedBy(u uint32) *TestcaseUpdate {
	tu.mutation.ResetUpdatedBy()
	tu.mutation.SetUpdatedBy(u)
	return tu
}

// SetNillableUpdatedBy sets the "updated_by" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillableUpdatedBy(u *uint32) *TestcaseUpdate {
	if u != nil {
		tu.SetUpdatedBy(*u)
	}
	return tu
}

// AddUpdatedBy adds u to the "updated_by" field.
func (tu *TestcaseUpdate) AddUpdatedBy(u int32) *TestcaseUpdate {
	tu.mutation.AddUpdatedBy(u)
	return tu
}

// ClearUpdatedBy clears the value of the "updated_by" field.
func (tu *TestcaseUpdate) ClearUpdatedBy() *TestcaseUpdate {
	tu.mutation.ClearUpdatedBy()
	return tu
}

// SetUpdatedAt sets the "updated_at" field.
func (tu *TestcaseUpdate) SetUpdatedAt(t time.Time) *TestcaseUpdate {
	tu.mutation.SetUpdatedAt(t)
	return tu
}

// ClearUpdatedAt clears the value of the "updated_at" field.
func (tu *TestcaseUpdate) ClearUpdatedAt() *TestcaseUpdate {
	tu.mutation.ClearUpdatedAt()
	return tu
}

// SetStatus sets the "status" field.
func (tu *TestcaseUpdate) SetStatus(i int8) *TestcaseUpdate {
	tu.mutation.ResetStatus()
	tu.mutation.SetStatus(i)
	return tu
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillableStatus(i *int8) *TestcaseUpdate {
	if i != nil {
		tu.SetStatus(*i)
	}
	return tu
}

// AddStatus adds i to the "status" field.
func (tu *TestcaseUpdate) AddStatus(i int8) *TestcaseUpdate {
	tu.mutation.AddStatus(i)
	return tu
}

// SetType sets the "type" field.
func (tu *TestcaseUpdate) SetType(i int8) *TestcaseUpdate {
	tu.mutation.ResetType()
	tu.mutation.SetType(i)
	return tu
}

// SetNillableType sets the "type" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillableType(i *int8) *TestcaseUpdate {
	if i != nil {
		tu.SetType(*i)
	}
	return tu
}

// AddType adds i to the "type" field.
func (tu *TestcaseUpdate) AddType(i int8) *TestcaseUpdate {
	tu.mutation.AddType(i)
	return tu
}

// SetPriority sets the "priority" field.
func (tu *TestcaseUpdate) SetPriority(i int8) *TestcaseUpdate {
	tu.mutation.ResetPriority()
	tu.mutation.SetPriority(i)
	return tu
}

// SetNillablePriority sets the "priority" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillablePriority(i *int8) *TestcaseUpdate {
	if i != nil {
		tu.SetPriority(*i)
	}
	return tu
}

// AddPriority adds i to the "priority" field.
func (tu *TestcaseUpdate) AddPriority(i int8) *TestcaseUpdate {
	tu.mutation.AddPriority(i)
	return tu
}

// SetDeletedAt sets the "deleted_at" field.
func (tu *TestcaseUpdate) SetDeletedAt(t time.Time) *TestcaseUpdate {
	tu.mutation.SetDeletedAt(t)
	return tu
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillableDeletedAt(t *time.Time) *TestcaseUpdate {
	if t != nil {
		tu.SetDeletedAt(*t)
	}
	return tu
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (tu *TestcaseUpdate) ClearDeletedAt() *TestcaseUpdate {
	tu.mutation.ClearDeletedAt()
	return tu
}

// SetDeletedBy sets the "deleted_by" field.
func (tu *TestcaseUpdate) SetDeletedBy(u uint32) *TestcaseUpdate {
	tu.mutation.ResetDeletedBy()
	tu.mutation.SetDeletedBy(u)
	return tu
}

// SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillableDeletedBy(u *uint32) *TestcaseUpdate {
	if u != nil {
		tu.SetDeletedBy(*u)
	}
	return tu
}

// AddDeletedBy adds u to the "deleted_by" field.
func (tu *TestcaseUpdate) AddDeletedBy(u int32) *TestcaseUpdate {
	tu.mutation.AddDeletedBy(u)
	return tu
}

// ClearDeletedBy clears the value of the "deleted_by" field.
func (tu *TestcaseUpdate) ClearDeletedBy() *TestcaseUpdate {
	tu.mutation.ClearDeletedBy()
	return tu
}

// SetDescription sets the "description" field.
func (tu *TestcaseUpdate) SetDescription(s string) *TestcaseUpdate {
	tu.mutation.SetDescription(s)
	return tu
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillableDescription(s *string) *TestcaseUpdate {
	if s != nil {
		tu.SetDescription(*s)
	}
	return tu
}

// ClearDescription clears the value of the "description" field.
func (tu *TestcaseUpdate) ClearDescription() *TestcaseUpdate {
	tu.mutation.ClearDescription()
	return tu
}

// SetLabel sets the "label" field.
func (tu *TestcaseUpdate) SetLabel(s string) *TestcaseUpdate {
	tu.mutation.SetLabel(s)
	return tu
}

// SetNillableLabel sets the "label" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillableLabel(s *string) *TestcaseUpdate {
	if s != nil {
		tu.SetLabel(*s)
	}
	return tu
}

// ClearLabel clears the value of the "label" field.
func (tu *TestcaseUpdate) ClearLabel() *TestcaseUpdate {
	tu.mutation.ClearLabel()
	return tu
}

// SetURL sets the "url" field.
func (tu *TestcaseUpdate) SetURL(s string) *TestcaseUpdate {
	tu.mutation.SetURL(s)
	return tu
}

// SetNillableURL sets the "url" field if the given value is not nil.
func (tu *TestcaseUpdate) SetNillableURL(s *string) *TestcaseUpdate {
	if s != nil {
		tu.SetURL(*s)
	}
	return tu
}

// ClearURL clears the value of the "url" field.
func (tu *TestcaseUpdate) ClearURL() *TestcaseUpdate {
	tu.mutation.ClearURL()
	return tu
}

// Mutation returns the TestcaseMutation object of the builder.
func (tu *TestcaseUpdate) Mutation() *TestcaseMutation {
	return tu.mutation
}

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

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

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

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

// defaults sets the default values of the builder before save.
func (tu *TestcaseUpdate) defaults() {
	if _, ok := tu.mutation.UpdatedAt(); !ok && !tu.mutation.UpdatedAtCleared() {
		v := testcase.UpdateDefaultUpdatedAt()
		tu.mutation.SetUpdatedAt(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (tu *TestcaseUpdate) check() error {
	if v, ok := tu.mutation.Name(); ok {
		if err := testcase.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Testcase.name": %w`, err)}
		}
	}
	return nil
}

func (tu *TestcaseUpdate) sqlSave(ctx context.Context) (n int, err error) {
	if err := tu.check(); err != nil {
		return n, err
	}
	_spec := sqlgraph.NewUpdateSpec(testcase.Table, testcase.Columns, sqlgraph.NewFieldSpec(testcase.FieldID, field.TypeInt32))
	if ps := tu.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := tu.mutation.Name(); ok {
		_spec.SetField(testcase.FieldName, field.TypeString, value)
	}
	if value, ok := tu.mutation.UpdatedBy(); ok {
		_spec.SetField(testcase.FieldUpdatedBy, field.TypeUint32, value)
	}
	if value, ok := tu.mutation.AddedUpdatedBy(); ok {
		_spec.AddField(testcase.FieldUpdatedBy, field.TypeUint32, value)
	}
	if tu.mutation.UpdatedByCleared() {
		_spec.ClearField(testcase.FieldUpdatedBy, field.TypeUint32)
	}
	if value, ok := tu.mutation.UpdatedAt(); ok {
		_spec.SetField(testcase.FieldUpdatedAt, field.TypeTime, value)
	}
	if tu.mutation.UpdatedAtCleared() {
		_spec.ClearField(testcase.FieldUpdatedAt, field.TypeTime)
	}
	if value, ok := tu.mutation.Status(); ok {
		_spec.SetField(testcase.FieldStatus, field.TypeInt8, value)
	}
	if value, ok := tu.mutation.AddedStatus(); ok {
		_spec.AddField(testcase.FieldStatus, field.TypeInt8, value)
	}
	if value, ok := tu.mutation.GetType(); ok {
		_spec.SetField(testcase.FieldType, field.TypeInt8, value)
	}
	if value, ok := tu.mutation.AddedType(); ok {
		_spec.AddField(testcase.FieldType, field.TypeInt8, value)
	}
	if value, ok := tu.mutation.Priority(); ok {
		_spec.SetField(testcase.FieldPriority, field.TypeInt8, value)
	}
	if value, ok := tu.mutation.AddedPriority(); ok {
		_spec.AddField(testcase.FieldPriority, field.TypeInt8, value)
	}
	if value, ok := tu.mutation.DeletedAt(); ok {
		_spec.SetField(testcase.FieldDeletedAt, field.TypeTime, value)
	}
	if tu.mutation.DeletedAtCleared() {
		_spec.ClearField(testcase.FieldDeletedAt, field.TypeTime)
	}
	if value, ok := tu.mutation.DeletedBy(); ok {
		_spec.SetField(testcase.FieldDeletedBy, field.TypeUint32, value)
	}
	if value, ok := tu.mutation.AddedDeletedBy(); ok {
		_spec.AddField(testcase.FieldDeletedBy, field.TypeUint32, value)
	}
	if tu.mutation.DeletedByCleared() {
		_spec.ClearField(testcase.FieldDeletedBy, field.TypeUint32)
	}
	if value, ok := tu.mutation.Description(); ok {
		_spec.SetField(testcase.FieldDescription, field.TypeString, value)
	}
	if tu.mutation.DescriptionCleared() {
		_spec.ClearField(testcase.FieldDescription, field.TypeString)
	}
	if value, ok := tu.mutation.Label(); ok {
		_spec.SetField(testcase.FieldLabel, field.TypeString, value)
	}
	if tu.mutation.LabelCleared() {
		_spec.ClearField(testcase.FieldLabel, field.TypeString)
	}
	if value, ok := tu.mutation.URL(); ok {
		_spec.SetField(testcase.FieldURL, field.TypeString, value)
	}
	if tu.mutation.URLCleared() {
		_spec.ClearField(testcase.FieldURL, field.TypeString)
	}
	if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{testcase.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	tu.mutation.done = true
	return n, nil
}

// TestcaseUpdateOne is the builder for updating a single Testcase entity.
type TestcaseUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *TestcaseMutation
}

// SetName sets the "name" field.
func (tuo *TestcaseUpdateOne) SetName(s string) *TestcaseUpdateOne {
	tuo.mutation.SetName(s)
	return tuo
}

// SetUpdatedBy sets the "updated_by" field.
func (tuo *TestcaseUpdateOne) SetUpdatedBy(u uint32) *TestcaseUpdateOne {
	tuo.mutation.ResetUpdatedBy()
	tuo.mutation.SetUpdatedBy(u)
	return tuo
}

// SetNillableUpdatedBy sets the "updated_by" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillableUpdatedBy(u *uint32) *TestcaseUpdateOne {
	if u != nil {
		tuo.SetUpdatedBy(*u)
	}
	return tuo
}

// AddUpdatedBy adds u to the "updated_by" field.
func (tuo *TestcaseUpdateOne) AddUpdatedBy(u int32) *TestcaseUpdateOne {
	tuo.mutation.AddUpdatedBy(u)
	return tuo
}

// ClearUpdatedBy clears the value of the "updated_by" field.
func (tuo *TestcaseUpdateOne) ClearUpdatedBy() *TestcaseUpdateOne {
	tuo.mutation.ClearUpdatedBy()
	return tuo
}

// SetUpdatedAt sets the "updated_at" field.
func (tuo *TestcaseUpdateOne) SetUpdatedAt(t time.Time) *TestcaseUpdateOne {
	tuo.mutation.SetUpdatedAt(t)
	return tuo
}

// ClearUpdatedAt clears the value of the "updated_at" field.
func (tuo *TestcaseUpdateOne) ClearUpdatedAt() *TestcaseUpdateOne {
	tuo.mutation.ClearUpdatedAt()
	return tuo
}

// SetStatus sets the "status" field.
func (tuo *TestcaseUpdateOne) SetStatus(i int8) *TestcaseUpdateOne {
	tuo.mutation.ResetStatus()
	tuo.mutation.SetStatus(i)
	return tuo
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillableStatus(i *int8) *TestcaseUpdateOne {
	if i != nil {
		tuo.SetStatus(*i)
	}
	return tuo
}

// AddStatus adds i to the "status" field.
func (tuo *TestcaseUpdateOne) AddStatus(i int8) *TestcaseUpdateOne {
	tuo.mutation.AddStatus(i)
	return tuo
}

// SetType sets the "type" field.
func (tuo *TestcaseUpdateOne) SetType(i int8) *TestcaseUpdateOne {
	tuo.mutation.ResetType()
	tuo.mutation.SetType(i)
	return tuo
}

// SetNillableType sets the "type" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillableType(i *int8) *TestcaseUpdateOne {
	if i != nil {
		tuo.SetType(*i)
	}
	return tuo
}

// AddType adds i to the "type" field.
func (tuo *TestcaseUpdateOne) AddType(i int8) *TestcaseUpdateOne {
	tuo.mutation.AddType(i)
	return tuo
}

// SetPriority sets the "priority" field.
func (tuo *TestcaseUpdateOne) SetPriority(i int8) *TestcaseUpdateOne {
	tuo.mutation.ResetPriority()
	tuo.mutation.SetPriority(i)
	return tuo
}

// SetNillablePriority sets the "priority" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillablePriority(i *int8) *TestcaseUpdateOne {
	if i != nil {
		tuo.SetPriority(*i)
	}
	return tuo
}

// AddPriority adds i to the "priority" field.
func (tuo *TestcaseUpdateOne) AddPriority(i int8) *TestcaseUpdateOne {
	tuo.mutation.AddPriority(i)
	return tuo
}

// SetDeletedAt sets the "deleted_at" field.
func (tuo *TestcaseUpdateOne) SetDeletedAt(t time.Time) *TestcaseUpdateOne {
	tuo.mutation.SetDeletedAt(t)
	return tuo
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillableDeletedAt(t *time.Time) *TestcaseUpdateOne {
	if t != nil {
		tuo.SetDeletedAt(*t)
	}
	return tuo
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (tuo *TestcaseUpdateOne) ClearDeletedAt() *TestcaseUpdateOne {
	tuo.mutation.ClearDeletedAt()
	return tuo
}

// SetDeletedBy sets the "deleted_by" field.
func (tuo *TestcaseUpdateOne) SetDeletedBy(u uint32) *TestcaseUpdateOne {
	tuo.mutation.ResetDeletedBy()
	tuo.mutation.SetDeletedBy(u)
	return tuo
}

// SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillableDeletedBy(u *uint32) *TestcaseUpdateOne {
	if u != nil {
		tuo.SetDeletedBy(*u)
	}
	return tuo
}

// AddDeletedBy adds u to the "deleted_by" field.
func (tuo *TestcaseUpdateOne) AddDeletedBy(u int32) *TestcaseUpdateOne {
	tuo.mutation.AddDeletedBy(u)
	return tuo
}

// ClearDeletedBy clears the value of the "deleted_by" field.
func (tuo *TestcaseUpdateOne) ClearDeletedBy() *TestcaseUpdateOne {
	tuo.mutation.ClearDeletedBy()
	return tuo
}

// SetDescription sets the "description" field.
func (tuo *TestcaseUpdateOne) SetDescription(s string) *TestcaseUpdateOne {
	tuo.mutation.SetDescription(s)
	return tuo
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillableDescription(s *string) *TestcaseUpdateOne {
	if s != nil {
		tuo.SetDescription(*s)
	}
	return tuo
}

// ClearDescription clears the value of the "description" field.
func (tuo *TestcaseUpdateOne) ClearDescription() *TestcaseUpdateOne {
	tuo.mutation.ClearDescription()
	return tuo
}

// SetLabel sets the "label" field.
func (tuo *TestcaseUpdateOne) SetLabel(s string) *TestcaseUpdateOne {
	tuo.mutation.SetLabel(s)
	return tuo
}

// SetNillableLabel sets the "label" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillableLabel(s *string) *TestcaseUpdateOne {
	if s != nil {
		tuo.SetLabel(*s)
	}
	return tuo
}

// ClearLabel clears the value of the "label" field.
func (tuo *TestcaseUpdateOne) ClearLabel() *TestcaseUpdateOne {
	tuo.mutation.ClearLabel()
	return tuo
}

// SetURL sets the "url" field.
func (tuo *TestcaseUpdateOne) SetURL(s string) *TestcaseUpdateOne {
	tuo.mutation.SetURL(s)
	return tuo
}

// SetNillableURL sets the "url" field if the given value is not nil.
func (tuo *TestcaseUpdateOne) SetNillableURL(s *string) *TestcaseUpdateOne {
	if s != nil {
		tuo.SetURL(*s)
	}
	return tuo
}

// ClearURL clears the value of the "url" field.
func (tuo *TestcaseUpdateOne) ClearURL() *TestcaseUpdateOne {
	tuo.mutation.ClearURL()
	return tuo
}

// Mutation returns the TestcaseMutation object of the builder.
func (tuo *TestcaseUpdateOne) Mutation() *TestcaseMutation {
	return tuo.mutation
}

// Where appends a list predicates to the TestcaseUpdate builder.
func (tuo *TestcaseUpdateOne) Where(ps ...predicate.Testcase) *TestcaseUpdateOne {
	tuo.mutation.Where(ps...)
	return tuo
}

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

// Save executes the query and returns the updated Testcase entity.
func (tuo *TestcaseUpdateOne) Save(ctx context.Context) (*Testcase, error) {
	tuo.defaults()
	return withHooks[*Testcase, TestcaseMutation](ctx, tuo.sqlSave, tuo.mutation, tuo.hooks)
}

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

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

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

// defaults sets the default values of the builder before save.
func (tuo *TestcaseUpdateOne) defaults() {
	if _, ok := tuo.mutation.UpdatedAt(); !ok && !tuo.mutation.UpdatedAtCleared() {
		v := testcase.UpdateDefaultUpdatedAt()
		tuo.mutation.SetUpdatedAt(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (tuo *TestcaseUpdateOne) check() error {
	if v, ok := tuo.mutation.Name(); ok {
		if err := testcase.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Testcase.name": %w`, err)}
		}
	}
	return nil
}

func (tuo *TestcaseUpdateOne) sqlSave(ctx context.Context) (_node *Testcase, err error) {
	if err := tuo.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(testcase.Table, testcase.Columns, sqlgraph.NewFieldSpec(testcase.FieldID, field.TypeInt32))
	id, ok := tuo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Testcase.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := tuo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, testcase.FieldID)
		for _, f := range fields {
			if !testcase.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != testcase.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := tuo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := tuo.mutation.Name(); ok {
		_spec.SetField(testcase.FieldName, field.TypeString, value)
	}
	if value, ok := tuo.mutation.UpdatedBy(); ok {
		_spec.SetField(testcase.FieldUpdatedBy, field.TypeUint32, value)
	}
	if value, ok := tuo.mutation.AddedUpdatedBy(); ok {
		_spec.AddField(testcase.FieldUpdatedBy, field.TypeUint32, value)
	}
	if tuo.mutation.UpdatedByCleared() {
		_spec.ClearField(testcase.FieldUpdatedBy, field.TypeUint32)
	}
	if value, ok := tuo.mutation.UpdatedAt(); ok {
		_spec.SetField(testcase.FieldUpdatedAt, field.TypeTime, value)
	}
	if tuo.mutation.UpdatedAtCleared() {
		_spec.ClearField(testcase.FieldUpdatedAt, field.TypeTime)
	}
	if value, ok := tuo.mutation.Status(); ok {
		_spec.SetField(testcase.FieldStatus, field.TypeInt8, value)
	}
	if value, ok := tuo.mutation.AddedStatus(); ok {
		_spec.AddField(testcase.FieldStatus, field.TypeInt8, value)
	}
	if value, ok := tuo.mutation.GetType(); ok {
		_spec.SetField(testcase.FieldType, field.TypeInt8, value)
	}
	if value, ok := tuo.mutation.AddedType(); ok {
		_spec.AddField(testcase.FieldType, field.TypeInt8, value)
	}
	if value, ok := tuo.mutation.Priority(); ok {
		_spec.SetField(testcase.FieldPriority, field.TypeInt8, value)
	}
	if value, ok := tuo.mutation.AddedPriority(); ok {
		_spec.AddField(testcase.FieldPriority, field.TypeInt8, value)
	}
	if value, ok := tuo.mutation.DeletedAt(); ok {
		_spec.SetField(testcase.FieldDeletedAt, field.TypeTime, value)
	}
	if tuo.mutation.DeletedAtCleared() {
		_spec.ClearField(testcase.FieldDeletedAt, field.TypeTime)
	}
	if value, ok := tuo.mutation.DeletedBy(); ok {
		_spec.SetField(testcase.FieldDeletedBy, field.TypeUint32, value)
	}
	if value, ok := tuo.mutation.AddedDeletedBy(); ok {
		_spec.AddField(testcase.FieldDeletedBy, field.TypeUint32, value)
	}
	if tuo.mutation.DeletedByCleared() {
		_spec.ClearField(testcase.FieldDeletedBy, field.TypeUint32)
	}
	if value, ok := tuo.mutation.Description(); ok {
		_spec.SetField(testcase.FieldDescription, field.TypeString, value)
	}
	if tuo.mutation.DescriptionCleared() {
		_spec.ClearField(testcase.FieldDescription, field.TypeString)
	}
	if value, ok := tuo.mutation.Label(); ok {
		_spec.SetField(testcase.FieldLabel, field.TypeString, value)
	}
	if tuo.mutation.LabelCleared() {
		_spec.ClearField(testcase.FieldLabel, field.TypeString)
	}
	if value, ok := tuo.mutation.URL(); ok {
		_spec.SetField(testcase.FieldURL, field.TypeString, value)
	}
	if tuo.mutation.URLCleared() {
		_spec.ClearField(testcase.FieldURL, field.TypeString)
	}
	_node = &Testcase{config: tuo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{testcase.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	tuo.mutation.done = true
	return _node, nil
}
