// 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/google/uuid"
	"github.com/in-toto/archivista/ent/dsse"
	"github.com/in-toto/archivista/ent/payloaddigest"
	"github.com/in-toto/archivista/ent/predicate"
	"github.com/in-toto/archivista/ent/signature"
	"github.com/in-toto/archivista/ent/statement"
)

// DsseUpdate is the builder for updating Dsse entities.
type DsseUpdate struct {
	config
	hooks    []Hook
	mutation *DsseMutation
}

// Where appends a list predicates to the DsseUpdate builder.
func (_u *DsseUpdate) Where(ps ...predicate.Dsse) *DsseUpdate {
	_u.mutation.Where(ps...)
	return _u
}

// SetGitoidSha256 sets the "gitoid_sha256" field.
func (_u *DsseUpdate) SetGitoidSha256(v string) *DsseUpdate {
	_u.mutation.SetGitoidSha256(v)
	return _u
}

// SetNillableGitoidSha256 sets the "gitoid_sha256" field if the given value is not nil.
func (_u *DsseUpdate) SetNillableGitoidSha256(v *string) *DsseUpdate {
	if v != nil {
		_u.SetGitoidSha256(*v)
	}
	return _u
}

// SetPayloadType sets the "payload_type" field.
func (_u *DsseUpdate) SetPayloadType(v string) *DsseUpdate {
	_u.mutation.SetPayloadType(v)
	return _u
}

// SetNillablePayloadType sets the "payload_type" field if the given value is not nil.
func (_u *DsseUpdate) SetNillablePayloadType(v *string) *DsseUpdate {
	if v != nil {
		_u.SetPayloadType(*v)
	}
	return _u
}

// SetStatementID sets the "statement" edge to the Statement entity by ID.
func (_u *DsseUpdate) SetStatementID(id uuid.UUID) *DsseUpdate {
	_u.mutation.SetStatementID(id)
	return _u
}

// SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil.
func (_u *DsseUpdate) SetNillableStatementID(id *uuid.UUID) *DsseUpdate {
	if id != nil {
		_u = _u.SetStatementID(*id)
	}
	return _u
}

// SetStatement sets the "statement" edge to the Statement entity.
func (_u *DsseUpdate) SetStatement(v *Statement) *DsseUpdate {
	return _u.SetStatementID(v.ID)
}

// AddSignatureIDs adds the "signatures" edge to the Signature entity by IDs.
func (_u *DsseUpdate) AddSignatureIDs(ids ...uuid.UUID) *DsseUpdate {
	_u.mutation.AddSignatureIDs(ids...)
	return _u
}

// AddSignatures adds the "signatures" edges to the Signature entity.
func (_u *DsseUpdate) AddSignatures(v ...*Signature) *DsseUpdate {
	ids := make([]uuid.UUID, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.AddSignatureIDs(ids...)
}

// AddPayloadDigestIDs adds the "payload_digests" edge to the PayloadDigest entity by IDs.
func (_u *DsseUpdate) AddPayloadDigestIDs(ids ...uuid.UUID) *DsseUpdate {
	_u.mutation.AddPayloadDigestIDs(ids...)
	return _u
}

// AddPayloadDigests adds the "payload_digests" edges to the PayloadDigest entity.
func (_u *DsseUpdate) AddPayloadDigests(v ...*PayloadDigest) *DsseUpdate {
	ids := make([]uuid.UUID, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.AddPayloadDigestIDs(ids...)
}

// Mutation returns the DsseMutation object of the builder.
func (_u *DsseUpdate) Mutation() *DsseMutation {
	return _u.mutation
}

// ClearStatement clears the "statement" edge to the Statement entity.
func (_u *DsseUpdate) ClearStatement() *DsseUpdate {
	_u.mutation.ClearStatement()
	return _u
}

// ClearSignatures clears all "signatures" edges to the Signature entity.
func (_u *DsseUpdate) ClearSignatures() *DsseUpdate {
	_u.mutation.ClearSignatures()
	return _u
}

// RemoveSignatureIDs removes the "signatures" edge to Signature entities by IDs.
func (_u *DsseUpdate) RemoveSignatureIDs(ids ...uuid.UUID) *DsseUpdate {
	_u.mutation.RemoveSignatureIDs(ids...)
	return _u
}

// RemoveSignatures removes "signatures" edges to Signature entities.
func (_u *DsseUpdate) RemoveSignatures(v ...*Signature) *DsseUpdate {
	ids := make([]uuid.UUID, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.RemoveSignatureIDs(ids...)
}

// ClearPayloadDigests clears all "payload_digests" edges to the PayloadDigest entity.
func (_u *DsseUpdate) ClearPayloadDigests() *DsseUpdate {
	_u.mutation.ClearPayloadDigests()
	return _u
}

// RemovePayloadDigestIDs removes the "payload_digests" edge to PayloadDigest entities by IDs.
func (_u *DsseUpdate) RemovePayloadDigestIDs(ids ...uuid.UUID) *DsseUpdate {
	_u.mutation.RemovePayloadDigestIDs(ids...)
	return _u
}

// RemovePayloadDigests removes "payload_digests" edges to PayloadDigest entities.
func (_u *DsseUpdate) RemovePayloadDigests(v ...*PayloadDigest) *DsseUpdate {
	ids := make([]uuid.UUID, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.RemovePayloadDigestIDs(ids...)
}

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

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

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

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

// check runs all checks and user-defined validators on the builder.
func (_u *DsseUpdate) check() error {
	if v, ok := _u.mutation.GitoidSha256(); ok {
		if err := dsse.GitoidSha256Validator(v); err != nil {
			return &ValidationError{Name: "gitoid_sha256", err: fmt.Errorf(`ent: validator failed for field "Dsse.gitoid_sha256": %w`, err)}
		}
	}
	if v, ok := _u.mutation.PayloadType(); ok {
		if err := dsse.PayloadTypeValidator(v); err != nil {
			return &ValidationError{Name: "payload_type", err: fmt.Errorf(`ent: validator failed for field "Dsse.payload_type": %w`, err)}
		}
	}
	return nil
}

func (_u *DsseUpdate) sqlSave(ctx context.Context) (_node int, err error) {
	if err := _u.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(dsse.Table, dsse.Columns, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID))
	if ps := _u.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if _u.mutation.CreatedAtCleared() {
		_spec.ClearField(dsse.FieldCreatedAt, field.TypeTime)
	}
	if value, ok := _u.mutation.GitoidSha256(); ok {
		_spec.SetField(dsse.FieldGitoidSha256, field.TypeString, value)
	}
	if value, ok := _u.mutation.PayloadType(); ok {
		_spec.SetField(dsse.FieldPayloadType, field.TypeString, value)
	}
	if _u.mutation.StatementCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   dsse.StatementTable,
			Columns: []string{dsse.StatementColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.StatementIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   dsse.StatementTable,
			Columns: []string{dsse.StatementColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if _u.mutation.SignaturesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.SignaturesTable,
			Columns: []string{dsse.SignaturesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.RemovedSignaturesIDs(); len(nodes) > 0 && !_u.mutation.SignaturesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.SignaturesTable,
			Columns: []string{dsse.SignaturesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(signature.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 := _u.mutation.SignaturesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.SignaturesTable,
			Columns: []string{dsse.SignaturesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if _u.mutation.PayloadDigestsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.PayloadDigestsTable,
			Columns: []string{dsse.PayloadDigestsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.RemovedPayloadDigestsIDs(); len(nodes) > 0 && !_u.mutation.PayloadDigestsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.PayloadDigestsTable,
			Columns: []string{dsse.PayloadDigestsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(payloaddigest.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 := _u.mutation.PayloadDigestsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.PayloadDigestsTable,
			Columns: []string{dsse.PayloadDigestsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{dsse.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	_u.mutation.done = true
	return _node, nil
}

// DsseUpdateOne is the builder for updating a single Dsse entity.
type DsseUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *DsseMutation
}

// SetGitoidSha256 sets the "gitoid_sha256" field.
func (_u *DsseUpdateOne) SetGitoidSha256(v string) *DsseUpdateOne {
	_u.mutation.SetGitoidSha256(v)
	return _u
}

// SetNillableGitoidSha256 sets the "gitoid_sha256" field if the given value is not nil.
func (_u *DsseUpdateOne) SetNillableGitoidSha256(v *string) *DsseUpdateOne {
	if v != nil {
		_u.SetGitoidSha256(*v)
	}
	return _u
}

// SetPayloadType sets the "payload_type" field.
func (_u *DsseUpdateOne) SetPayloadType(v string) *DsseUpdateOne {
	_u.mutation.SetPayloadType(v)
	return _u
}

// SetNillablePayloadType sets the "payload_type" field if the given value is not nil.
func (_u *DsseUpdateOne) SetNillablePayloadType(v *string) *DsseUpdateOne {
	if v != nil {
		_u.SetPayloadType(*v)
	}
	return _u
}

// SetStatementID sets the "statement" edge to the Statement entity by ID.
func (_u *DsseUpdateOne) SetStatementID(id uuid.UUID) *DsseUpdateOne {
	_u.mutation.SetStatementID(id)
	return _u
}

// SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil.
func (_u *DsseUpdateOne) SetNillableStatementID(id *uuid.UUID) *DsseUpdateOne {
	if id != nil {
		_u = _u.SetStatementID(*id)
	}
	return _u
}

// SetStatement sets the "statement" edge to the Statement entity.
func (_u *DsseUpdateOne) SetStatement(v *Statement) *DsseUpdateOne {
	return _u.SetStatementID(v.ID)
}

// AddSignatureIDs adds the "signatures" edge to the Signature entity by IDs.
func (_u *DsseUpdateOne) AddSignatureIDs(ids ...uuid.UUID) *DsseUpdateOne {
	_u.mutation.AddSignatureIDs(ids...)
	return _u
}

// AddSignatures adds the "signatures" edges to the Signature entity.
func (_u *DsseUpdateOne) AddSignatures(v ...*Signature) *DsseUpdateOne {
	ids := make([]uuid.UUID, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.AddSignatureIDs(ids...)
}

// AddPayloadDigestIDs adds the "payload_digests" edge to the PayloadDigest entity by IDs.
func (_u *DsseUpdateOne) AddPayloadDigestIDs(ids ...uuid.UUID) *DsseUpdateOne {
	_u.mutation.AddPayloadDigestIDs(ids...)
	return _u
}

// AddPayloadDigests adds the "payload_digests" edges to the PayloadDigest entity.
func (_u *DsseUpdateOne) AddPayloadDigests(v ...*PayloadDigest) *DsseUpdateOne {
	ids := make([]uuid.UUID, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.AddPayloadDigestIDs(ids...)
}

// Mutation returns the DsseMutation object of the builder.
func (_u *DsseUpdateOne) Mutation() *DsseMutation {
	return _u.mutation
}

// ClearStatement clears the "statement" edge to the Statement entity.
func (_u *DsseUpdateOne) ClearStatement() *DsseUpdateOne {
	_u.mutation.ClearStatement()
	return _u
}

// ClearSignatures clears all "signatures" edges to the Signature entity.
func (_u *DsseUpdateOne) ClearSignatures() *DsseUpdateOne {
	_u.mutation.ClearSignatures()
	return _u
}

// RemoveSignatureIDs removes the "signatures" edge to Signature entities by IDs.
func (_u *DsseUpdateOne) RemoveSignatureIDs(ids ...uuid.UUID) *DsseUpdateOne {
	_u.mutation.RemoveSignatureIDs(ids...)
	return _u
}

// RemoveSignatures removes "signatures" edges to Signature entities.
func (_u *DsseUpdateOne) RemoveSignatures(v ...*Signature) *DsseUpdateOne {
	ids := make([]uuid.UUID, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.RemoveSignatureIDs(ids...)
}

// ClearPayloadDigests clears all "payload_digests" edges to the PayloadDigest entity.
func (_u *DsseUpdateOne) ClearPayloadDigests() *DsseUpdateOne {
	_u.mutation.ClearPayloadDigests()
	return _u
}

// RemovePayloadDigestIDs removes the "payload_digests" edge to PayloadDigest entities by IDs.
func (_u *DsseUpdateOne) RemovePayloadDigestIDs(ids ...uuid.UUID) *DsseUpdateOne {
	_u.mutation.RemovePayloadDigestIDs(ids...)
	return _u
}

// RemovePayloadDigests removes "payload_digests" edges to PayloadDigest entities.
func (_u *DsseUpdateOne) RemovePayloadDigests(v ...*PayloadDigest) *DsseUpdateOne {
	ids := make([]uuid.UUID, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _u.RemovePayloadDigestIDs(ids...)
}

// Where appends a list predicates to the DsseUpdate builder.
func (_u *DsseUpdateOne) Where(ps ...predicate.Dsse) *DsseUpdateOne {
	_u.mutation.Where(ps...)
	return _u
}

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

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

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

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

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

// check runs all checks and user-defined validators on the builder.
func (_u *DsseUpdateOne) check() error {
	if v, ok := _u.mutation.GitoidSha256(); ok {
		if err := dsse.GitoidSha256Validator(v); err != nil {
			return &ValidationError{Name: "gitoid_sha256", err: fmt.Errorf(`ent: validator failed for field "Dsse.gitoid_sha256": %w`, err)}
		}
	}
	if v, ok := _u.mutation.PayloadType(); ok {
		if err := dsse.PayloadTypeValidator(v); err != nil {
			return &ValidationError{Name: "payload_type", err: fmt.Errorf(`ent: validator failed for field "Dsse.payload_type": %w`, err)}
		}
	}
	return nil
}

func (_u *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) {
	if err := _u.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(dsse.Table, dsse.Columns, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID))
	id, ok := _u.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Dsse.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := _u.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, dsse.FieldID)
		for _, f := range fields {
			if !dsse.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != dsse.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := _u.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if _u.mutation.CreatedAtCleared() {
		_spec.ClearField(dsse.FieldCreatedAt, field.TypeTime)
	}
	if value, ok := _u.mutation.GitoidSha256(); ok {
		_spec.SetField(dsse.FieldGitoidSha256, field.TypeString, value)
	}
	if value, ok := _u.mutation.PayloadType(); ok {
		_spec.SetField(dsse.FieldPayloadType, field.TypeString, value)
	}
	if _u.mutation.StatementCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   dsse.StatementTable,
			Columns: []string{dsse.StatementColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.StatementIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   dsse.StatementTable,
			Columns: []string{dsse.StatementColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if _u.mutation.SignaturesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.SignaturesTable,
			Columns: []string{dsse.SignaturesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.RemovedSignaturesIDs(); len(nodes) > 0 && !_u.mutation.SignaturesCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.SignaturesTable,
			Columns: []string{dsse.SignaturesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(signature.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 := _u.mutation.SignaturesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.SignaturesTable,
			Columns: []string{dsse.SignaturesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if _u.mutation.PayloadDigestsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.PayloadDigestsTable,
			Columns: []string{dsse.PayloadDigestsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.RemovedPayloadDigestsIDs(); len(nodes) > 0 && !_u.mutation.PayloadDigestsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.PayloadDigestsTable,
			Columns: []string{dsse.PayloadDigestsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(payloaddigest.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 := _u.mutation.PayloadDigestsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   dsse.PayloadDigestsTable,
			Columns: []string{dsse.PayloadDigestsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_node = &Dsse{config: _u.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{dsse.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	_u.mutation.done = true
	return _node, nil
}
