| 1 |
// Code generated by ent, DO NOT EDIT. |
| 2 |
|
| 3 |
package ent |
| 4 |
|
| 5 |
import ( |
| 6 |
"context" |
| 7 |
"errors" |
| 8 |
"fmt" |
| 9 |
|
| 10 |
"entgo.io/ent/dialect/sql" |
| 11 |
"entgo.io/ent/dialect/sql/sqlgraph" |
| 12 |
"entgo.io/ent/schema/field" |
| 13 |
"github.com/google/uuid" |
| 14 |
"github.com/in-toto/archivista/ent/predicate" |
| 15 |
"github.com/in-toto/archivista/ent/statement" |
| 16 |
"github.com/in-toto/archivista/ent/subject" |
| 17 |
"github.com/in-toto/archivista/ent/subjectdigest" |
| 18 |
) |
| 19 |
|
| 20 |
// SubjectUpdate is the builder for updating Subject entities. |
| 21 |
type SubjectUpdate struct { |
| 22 |
config |
| 23 |
hooks []Hook |
| 24 |
mutation *SubjectMutation |
| 25 |
} |
| 26 |
|
| 27 |
// Where appends a list predicates to the SubjectUpdate builder. |
| 28 |
func (_u *SubjectUpdate) Where(ps ...predicate.Subject) *SubjectUpdate { |
| 29 |
_u.mutation.Where(ps...) |
| 30 |
return _u |
| 31 |
} |
| 32 |
|
| 33 |
// SetName sets the "name" field. |
| 34 |
func (_u *SubjectUpdate) SetName(v string) *SubjectUpdate { |
| 35 |
_u.mutation.SetName(v) |
| 36 |
return _u |
| 37 |
} |
| 38 |
|
| 39 |
// SetNillableName sets the "name" field if the given value is not nil. |
| 40 |
func (_u *SubjectUpdate) SetNillableName(v *string) *SubjectUpdate { |
| 41 |
if v != nil { |
| 42 |
_u.SetName(*v) |
| 43 |
} |
| 44 |
return _u |
| 45 |
} |
| 46 |
|
| 47 |
// AddSubjectDigestIDs adds the "subject_digests" edge to the SubjectDigest entity by IDs. |
| 48 |
func (_u *SubjectUpdate) AddSubjectDigestIDs(ids ...uuid.UUID) *SubjectUpdate { |
| 49 |
_u.mutation.AddSubjectDigestIDs(ids...) |
| 50 |
return _u |
| 51 |
} |
| 52 |
|
| 53 |
// AddSubjectDigests adds the "subject_digests" edges to the SubjectDigest entity. |
| 54 |
func (_u *SubjectUpdate) AddSubjectDigests(v ...*SubjectDigest) *SubjectUpdate { |
| 55 |
ids := make([]uuid.UUID, len(v)) |
| 56 |
for i := range v { |
| 57 |
ids[i] = v[i].ID |
| 58 |
} |
| 59 |
return _u.AddSubjectDigestIDs(ids...) |
| 60 |
} |
| 61 |
|
| 62 |
// SetStatementID sets the "statement" edge to the Statement entity by ID. |
| 63 |
func (_u *SubjectUpdate) SetStatementID(id uuid.UUID) *SubjectUpdate { |
| 64 |
_u.mutation.SetStatementID(id) |
| 65 |
return _u |
| 66 |
} |
| 67 |
|
| 68 |
// SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. |
| 69 |
func (_u *SubjectUpdate) SetNillableStatementID(id *uuid.UUID) *SubjectUpdate { |
| 70 |
if id != nil { |
| 71 |
_u = _u.SetStatementID(*id) |
| 72 |
} |
| 73 |
return _u |
| 74 |
} |
| 75 |
|
| 76 |
// SetStatement sets the "statement" edge to the Statement entity. |
| 77 |
func (_u *SubjectUpdate) SetStatement(v *Statement) *SubjectUpdate { |
| 78 |
return _u.SetStatementID(v.ID) |
| 79 |
} |
| 80 |
|
| 81 |
// Mutation returns the SubjectMutation object of the builder. |
| 82 |
func (_u *SubjectUpdate) Mutation() *SubjectMutation { |
| 83 |
return _u.mutation |
| 84 |
} |
| 85 |
|
| 86 |
// ClearSubjectDigests clears all "subject_digests" edges to the SubjectDigest entity. |
| 87 |
func (_u *SubjectUpdate) ClearSubjectDigests() *SubjectUpdate { |
| 88 |
_u.mutation.ClearSubjectDigests() |
| 89 |
return _u |
| 90 |
} |
| 91 |
|
| 92 |
// RemoveSubjectDigestIDs removes the "subject_digests" edge to SubjectDigest entities by IDs. |
| 93 |
func (_u *SubjectUpdate) RemoveSubjectDigestIDs(ids ...uuid.UUID) *SubjectUpdate { |
| 94 |
_u.mutation.RemoveSubjectDigestIDs(ids...) |
| 95 |
return _u |
| 96 |
} |
| 97 |
|
| 98 |
// RemoveSubjectDigests removes "subject_digests" edges to SubjectDigest entities. |
| 99 |
func (_u *SubjectUpdate) RemoveSubjectDigests(v ...*SubjectDigest) *SubjectUpdate { |
| 100 |
ids := make([]uuid.UUID, len(v)) |
| 101 |
for i := range v { |
| 102 |
ids[i] = v[i].ID |
| 103 |
} |
| 104 |
return _u.RemoveSubjectDigestIDs(ids...) |
| 105 |
} |
| 106 |
|
| 107 |
// ClearStatement clears the "statement" edge to the Statement entity. |
| 108 |
func (_u *SubjectUpdate) ClearStatement() *SubjectUpdate { |
| 109 |
_u.mutation.ClearStatement() |
| 110 |
return _u |
| 111 |
} |
| 112 |
|
| 113 |
// Save executes the query and returns the number of nodes affected by the update operation. |
| 114 |
func (_u *SubjectUpdate) Save(ctx context.Context) (int, error) { |
| 115 |
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) |
| 116 |
} |
| 117 |
|
| 118 |
// SaveX is like Save, but panics if an error occurs. |
| 119 |
func (_u *SubjectUpdate) SaveX(ctx context.Context) int { |
| 120 |
affected, err := _u.Save(ctx) |
| 121 |
if err != nil { |
| 122 |
panic(err) |
| 123 |
} |
| 124 |
return affected |
| 125 |
} |
| 126 |
|
| 127 |
// Exec executes the query. |
| 128 |
func (_u *SubjectUpdate) Exec(ctx context.Context) error { |
| 129 |
_, err := _u.Save(ctx) |
| 130 |
return err |
| 131 |
} |
| 132 |
|
| 133 |
// ExecX is like Exec, but panics if an error occurs. |
| 134 |
func (_u *SubjectUpdate) ExecX(ctx context.Context) { |
| 135 |
if err := _u.Exec(ctx); err != nil { |
| 136 |
panic(err) |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
// check runs all checks and user-defined validators on the builder. |
| 141 |
func (_u *SubjectUpdate) check() error { |
| 142 |
if v, ok := _u.mutation.Name(); ok { |
| 143 |
if err := subject.NameValidator(v); err != nil { |
| 144 |
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Subject.name": %w`, err)} |
| 145 |
} |
| 146 |
} |
| 147 |
return nil |
| 148 |
} |
| 149 |
|
| 150 |
func (_u *SubjectUpdate) sqlSave(ctx context.Context) (_node int, err error) { |
| 151 |
if err := _u.check(); err != nil { |
| 152 |
return _node, err |
| 153 |
} |
| 154 |
_spec := sqlgraph.NewUpdateSpec(subject.Table, subject.Columns, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID)) |
| 155 |
if ps := _u.mutation.predicates; len(ps) > 0 { |
| 156 |
_spec.Predicate = func(selector *sql.Selector) { |
| 157 |
for i := range ps { |
| 158 |
ps[i](selector) |
| 159 |
} |
| 160 |
} |
| 161 |
} |
| 162 |
if _u.mutation.CreatedAtCleared() { |
| 163 |
_spec.ClearField(subject.FieldCreatedAt, field.TypeTime) |
| 164 |
} |
| 165 |
if value, ok := _u.mutation.Name(); ok { |
| 166 |
_spec.SetField(subject.FieldName, field.TypeString, value) |
| 167 |
} |
| 168 |
if _u.mutation.SubjectDigestsCleared() { |
| 169 |
edge := &sqlgraph.EdgeSpec{ |
| 170 |
Rel: sqlgraph.O2M, |
| 171 |
Inverse: false, |
| 172 |
Table: subject.SubjectDigestsTable, |
| 173 |
Columns: []string{subject.SubjectDigestsColumn}, |
| 174 |
Bidi: false, |
| 175 |
Target: &sqlgraph.EdgeTarget{ |
| 176 |
IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), |
| 177 |
}, |
| 178 |
} |
| 179 |
_spec.Edges.Clear = append(_spec.Edges.Clear, edge) |
| 180 |
} |
| 181 |
if nodes := _u.mutation.RemovedSubjectDigestsIDs(); len(nodes) > 0 && !_u.mutation.SubjectDigestsCleared() { |
| 182 |
edge := &sqlgraph.EdgeSpec{ |
| 183 |
Rel: sqlgraph.O2M, |
| 184 |
Inverse: false, |
| 185 |
Table: subject.SubjectDigestsTable, |
| 186 |
Columns: []string{subject.SubjectDigestsColumn}, |
| 187 |
Bidi: false, |
| 188 |
Target: &sqlgraph.EdgeTarget{ |
| 189 |
IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), |
| 190 |
}, |
| 191 |
} |
| 192 |
for _, k := range nodes { |
| 193 |
edge.Target.Nodes = append(edge.Target.Nodes, k) |
| 194 |
} |
| 195 |
_spec.Edges.Clear = append(_spec.Edges.Clear, edge) |
| 196 |
} |
| 197 |
if nodes := _u.mutation.SubjectDigestsIDs(); len(nodes) > 0 { |
| 198 |
edge := &sqlgraph.EdgeSpec{ |
| 199 |
Rel: sqlgraph.O2M, |
| 200 |
Inverse: false, |
| 201 |
Table: subject.SubjectDigestsTable, |
| 202 |
Columns: []string{subject.SubjectDigestsColumn}, |
| 203 |
Bidi: false, |
| 204 |
Target: &sqlgraph.EdgeTarget{ |
| 205 |
IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), |
| 206 |
}, |
| 207 |
} |
| 208 |
for _, k := range nodes { |
| 209 |
edge.Target.Nodes = append(edge.Target.Nodes, k) |
| 210 |
} |
| 211 |
_spec.Edges.Add = append(_spec.Edges.Add, edge) |
| 212 |
} |
| 213 |
if _u.mutation.StatementCleared() { |
| 214 |
edge := &sqlgraph.EdgeSpec{ |
| 215 |
Rel: sqlgraph.M2O, |
| 216 |
Inverse: true, |
| 217 |
Table: subject.StatementTable, |
| 218 |
Columns: []string{subject.StatementColumn}, |
| 219 |
Bidi: false, |
| 220 |
Target: &sqlgraph.EdgeTarget{ |
| 221 |
IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), |
| 222 |
}, |
| 223 |
} |
| 224 |
_spec.Edges.Clear = append(_spec.Edges.Clear, edge) |
| 225 |
} |
| 226 |
if nodes := _u.mutation.StatementIDs(); len(nodes) > 0 { |
| 227 |
edge := &sqlgraph.EdgeSpec{ |
| 228 |
Rel: sqlgraph.M2O, |
| 229 |
Inverse: true, |
| 230 |
Table: subject.StatementTable, |
| 231 |
Columns: []string{subject.StatementColumn}, |
| 232 |
Bidi: false, |
| 233 |
Target: &sqlgraph.EdgeTarget{ |
| 234 |
IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), |
| 235 |
}, |
| 236 |
} |
| 237 |
for _, k := range nodes { |
| 238 |
edge.Target.Nodes = append(edge.Target.Nodes, k) |
| 239 |
} |
| 240 |
_spec.Edges.Add = append(_spec.Edges.Add, edge) |
| 241 |
} |
| 242 |
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { |
| 243 |
if _, ok := err.(*sqlgraph.NotFoundError); ok { |
| 244 |
err = &NotFoundError{subject.Label} |
| 245 |
} else if sqlgraph.IsConstraintError(err) { |
| 246 |
err = &ConstraintError{msg: err.Error(), wrap: err} |
| 247 |
} |
| 248 |
return 0, err |
| 249 |
} |
| 250 |
_u.mutation.done = true |
| 251 |
return _node, nil |
| 252 |
} |
| 253 |
|
| 254 |
// SubjectUpdateOne is the builder for updating a single Subject entity. |
| 255 |
type SubjectUpdateOne struct { |
| 256 |
config |
| 257 |
fields []string |
| 258 |
hooks []Hook |
| 259 |
mutation *SubjectMutation |
| 260 |
} |
| 261 |
|
| 262 |
// SetName sets the "name" field. |
| 263 |
func (_u *SubjectUpdateOne) SetName(v string) *SubjectUpdateOne { |
| 264 |
_u.mutation.SetName(v) |
| 265 |
return _u |
| 266 |
} |
| 267 |
|
| 268 |
// SetNillableName sets the "name" field if the given value is not nil. |
| 269 |
func (_u *SubjectUpdateOne) SetNillableName(v *string) *SubjectUpdateOne { |
| 270 |
if v != nil { |
| 271 |
_u.SetName(*v) |
| 272 |
} |
| 273 |
return _u |
| 274 |
} |
| 275 |
|
| 276 |
// AddSubjectDigestIDs adds the "subject_digests" edge to the SubjectDigest entity by IDs. |
| 277 |
func (_u *SubjectUpdateOne) AddSubjectDigestIDs(ids ...uuid.UUID) *SubjectUpdateOne { |
| 278 |
_u.mutation.AddSubjectDigestIDs(ids...) |
| 279 |
return _u |
| 280 |
} |
| 281 |
|
| 282 |
// AddSubjectDigests adds the "subject_digests" edges to the SubjectDigest entity. |
| 283 |
func (_u *SubjectUpdateOne) AddSubjectDigests(v ...*SubjectDigest) *SubjectUpdateOne { |
| 284 |
ids := make([]uuid.UUID, len(v)) |
| 285 |
for i := range v { |
| 286 |
ids[i] = v[i].ID |
| 287 |
} |
| 288 |
return _u.AddSubjectDigestIDs(ids...) |
| 289 |
} |
| 290 |
|
| 291 |
// SetStatementID sets the "statement" edge to the Statement entity by ID. |
| 292 |
func (_u *SubjectUpdateOne) SetStatementID(id uuid.UUID) *SubjectUpdateOne { |
| 293 |
_u.mutation.SetStatementID(id) |
| 294 |
return _u |
| 295 |
} |
| 296 |
|
| 297 |
// SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. |
| 298 |
func (_u *SubjectUpdateOne) SetNillableStatementID(id *uuid.UUID) *SubjectUpdateOne { |
| 299 |
if id != nil { |
| 300 |
_u = _u.SetStatementID(*id) |
| 301 |
} |
| 302 |
return _u |
| 303 |
} |
| 304 |
|
| 305 |
// SetStatement sets the "statement" edge to the Statement entity. |
| 306 |
func (_u *SubjectUpdateOne) SetStatement(v *Statement) *SubjectUpdateOne { |
| 307 |
return _u.SetStatementID(v.ID) |
| 308 |
} |
| 309 |
|
| 310 |
// Mutation returns the SubjectMutation object of the builder. |
| 311 |
func (_u *SubjectUpdateOne) Mutation() *SubjectMutation { |
| 312 |
return _u.mutation |
| 313 |
} |
| 314 |
|
| 315 |
// ClearSubjectDigests clears all "subject_digests" edges to the SubjectDigest entity. |
| 316 |
func (_u *SubjectUpdateOne) ClearSubjectDigests() *SubjectUpdateOne { |
| 317 |
_u.mutation.ClearSubjectDigests() |
| 318 |
return _u |
| 319 |
} |
| 320 |
|
| 321 |
// RemoveSubjectDigestIDs removes the "subject_digests" edge to SubjectDigest entities by IDs. |
| 322 |
func (_u *SubjectUpdateOne) RemoveSubjectDigestIDs(ids ...uuid.UUID) *SubjectUpdateOne { |
| 323 |
_u.mutation.RemoveSubjectDigestIDs(ids...) |
| 324 |
return _u |
| 325 |
} |
| 326 |
|
| 327 |
// RemoveSubjectDigests removes "subject_digests" edges to SubjectDigest entities. |
| 328 |
func (_u *SubjectUpdateOne) RemoveSubjectDigests(v ...*SubjectDigest) *SubjectUpdateOne { |
| 329 |
ids := make([]uuid.UUID, len(v)) |
| 330 |
for i := range v { |
| 331 |
ids[i] = v[i].ID |
| 332 |
} |
| 333 |
return _u.RemoveSubjectDigestIDs(ids...) |
| 334 |
} |
| 335 |
|
| 336 |
// ClearStatement clears the "statement" edge to the Statement entity. |
| 337 |
func (_u *SubjectUpdateOne) ClearStatement() *SubjectUpdateOne { |
| 338 |
_u.mutation.ClearStatement() |
| 339 |
return _u |
| 340 |
} |
| 341 |
|
| 342 |
// Where appends a list predicates to the SubjectUpdate builder. |
| 343 |
func (_u *SubjectUpdateOne) Where(ps ...predicate.Subject) *SubjectUpdateOne { |
| 344 |
_u.mutation.Where(ps...) |
| 345 |
return _u |
| 346 |
} |
| 347 |
|
| 348 |
// Select allows selecting one or more fields (columns) of the returned entity. |
| 349 |
// The default is selecting all fields defined in the entity schema. |
| 350 |
func (_u *SubjectUpdateOne) Select(field string, fields ...string) *SubjectUpdateOne { |
| 351 |
_u.fields = append([]string{field}, fields...) |
| 352 |
return _u |
| 353 |
} |
| 354 |
|
| 355 |
// Save executes the query and returns the updated Subject entity. |
| 356 |
func (_u *SubjectUpdateOne) Save(ctx context.Context) (*Subject, error) { |
| 357 |
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) |
| 358 |
} |
| 359 |
|
| 360 |
// SaveX is like Save, but panics if an error occurs. |
| 361 |
func (_u *SubjectUpdateOne) SaveX(ctx context.Context) *Subject { |
| 362 |
node, err := _u.Save(ctx) |
| 363 |
if err != nil { |
| 364 |
panic(err) |
| 365 |
} |
| 366 |
return node |
| 367 |
} |
| 368 |
|
| 369 |
// Exec executes the query on the entity. |
| 370 |
func (_u *SubjectUpdateOne) Exec(ctx context.Context) error { |
| 371 |
_, err := _u.Save(ctx) |
| 372 |
return err |
| 373 |
} |
| 374 |
|
| 375 |
// ExecX is like Exec, but panics if an error occurs. |
| 376 |
func (_u *SubjectUpdateOne) ExecX(ctx context.Context) { |
| 377 |
if err := _u.Exec(ctx); err != nil { |
| 378 |
panic(err) |
| 379 |
} |
| 380 |
} |
| 381 |
|
| 382 |
// check runs all checks and user-defined validators on the builder. |
| 383 |
func (_u *SubjectUpdateOne) check() error { |
| 384 |
if v, ok := _u.mutation.Name(); ok { |
| 385 |
if err := subject.NameValidator(v); err != nil { |
| 386 |
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Subject.name": %w`, err)} |
| 387 |
} |
| 388 |
} |
| 389 |
return nil |
| 390 |
} |
| 391 |
|
| 392 |
func (_u *SubjectUpdateOne) sqlSave(ctx context.Context) (_node *Subject, err error) { |
| 393 |
if err := _u.check(); err != nil { |
| 394 |
return _node, err |
| 395 |
} |
| 396 |
_spec := sqlgraph.NewUpdateSpec(subject.Table, subject.Columns, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID)) |
| 397 |
id, ok := _u.mutation.ID() |
| 398 |
if !ok { |
| 399 |
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Subject.id" for update`)} |
| 400 |
} |
| 401 |
_spec.Node.ID.Value = id |
| 402 |
if fields := _u.fields; len(fields) > 0 { |
| 403 |
_spec.Node.Columns = make([]string, 0, len(fields)) |
| 404 |
_spec.Node.Columns = append(_spec.Node.Columns, subject.FieldID) |
| 405 |
for _, f := range fields { |
| 406 |
if !subject.ValidColumn(f) { |
| 407 |
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} |
| 408 |
} |
| 409 |
if f != subject.FieldID { |
| 410 |
_spec.Node.Columns = append(_spec.Node.Columns, f) |
| 411 |
} |
| 412 |
} |
| 413 |
} |
| 414 |
if ps := _u.mutation.predicates; len(ps) > 0 { |
| 415 |
_spec.Predicate = func(selector *sql.Selector) { |
| 416 |
for i := range ps { |
| 417 |
ps[i](selector) |
| 418 |
} |
| 419 |
} |
| 420 |
} |
| 421 |
if _u.mutation.CreatedAtCleared() { |
| 422 |
_spec.ClearField(subject.FieldCreatedAt, field.TypeTime) |
| 423 |
} |
| 424 |
if value, ok := _u.mutation.Name(); ok { |
| 425 |
_spec.SetField(subject.FieldName, field.TypeString, value) |
| 426 |
} |
| 427 |
if _u.mutation.SubjectDigestsCleared() { |
| 428 |
edge := &sqlgraph.EdgeSpec{ |
| 429 |
Rel: sqlgraph.O2M, |
| 430 |
Inverse: false, |
| 431 |
Table: subject.SubjectDigestsTable, |
| 432 |
Columns: []string{subject.SubjectDigestsColumn}, |
| 433 |
Bidi: false, |
| 434 |
Target: &sqlgraph.EdgeTarget{ |
| 435 |
IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), |
| 436 |
}, |
| 437 |
} |
| 438 |
_spec.Edges.Clear = append(_spec.Edges.Clear, edge) |
| 439 |
} |
| 440 |
if nodes := _u.mutation.RemovedSubjectDigestsIDs(); len(nodes) > 0 && !_u.mutation.SubjectDigestsCleared() { |
| 441 |
edge := &sqlgraph.EdgeSpec{ |
| 442 |
Rel: sqlgraph.O2M, |
| 443 |
Inverse: false, |
| 444 |
Table: subject.SubjectDigestsTable, |
| 445 |
Columns: []string{subject.SubjectDigestsColumn}, |
| 446 |
Bidi: false, |
| 447 |
Target: &sqlgraph.EdgeTarget{ |
| 448 |
IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), |
| 449 |
}, |
| 450 |
} |
| 451 |
for _, k := range nodes { |
| 452 |
edge.Target.Nodes = append(edge.Target.Nodes, k) |
| 453 |
} |
| 454 |
_spec.Edges.Clear = append(_spec.Edges.Clear, edge) |
| 455 |
} |
| 456 |
if nodes := _u.mutation.SubjectDigestsIDs(); len(nodes) > 0 { |
| 457 |
edge := &sqlgraph.EdgeSpec{ |
| 458 |
Rel: sqlgraph.O2M, |
| 459 |
Inverse: false, |
| 460 |
Table: subject.SubjectDigestsTable, |
| 461 |
Columns: []string{subject.SubjectDigestsColumn}, |
| 462 |
Bidi: false, |
| 463 |
Target: &sqlgraph.EdgeTarget{ |
| 464 |
IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), |
| 465 |
}, |
| 466 |
} |
| 467 |
for _, k := range nodes { |
| 468 |
edge.Target.Nodes = append(edge.Target.Nodes, k) |
| 469 |
} |
| 470 |
_spec.Edges.Add = append(_spec.Edges.Add, edge) |
| 471 |
} |
| 472 |
if _u.mutation.StatementCleared() { |
| 473 |
edge := &sqlgraph.EdgeSpec{ |
| 474 |
Rel: sqlgraph.M2O, |
| 475 |
Inverse: true, |
| 476 |
Table: subject.StatementTable, |
| 477 |
Columns: []string{subject.StatementColumn}, |
| 478 |
Bidi: false, |
| 479 |
Target: &sqlgraph.EdgeTarget{ |
| 480 |
IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), |
| 481 |
}, |
| 482 |
} |
| 483 |
_spec.Edges.Clear = append(_spec.Edges.Clear, edge) |
| 484 |
} |
| 485 |
if nodes := _u.mutation.StatementIDs(); len(nodes) > 0 { |
| 486 |
edge := &sqlgraph.EdgeSpec{ |
| 487 |
Rel: sqlgraph.M2O, |
| 488 |
Inverse: true, |
| 489 |
Table: subject.StatementTable, |
| 490 |
Columns: []string{subject.StatementColumn}, |
| 491 |
Bidi: false, |
| 492 |
Target: &sqlgraph.EdgeTarget{ |
| 493 |
IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), |
| 494 |
}, |
| 495 |
} |
| 496 |
for _, k := range nodes { |
| 497 |
edge.Target.Nodes = append(edge.Target.Nodes, k) |
| 498 |
} |
| 499 |
_spec.Edges.Add = append(_spec.Edges.Add, edge) |
| 500 |
} |
| 501 |
_node = &Subject{config: _u.config} |
| 502 |
_spec.Assign = _node.assignValues |
| 503 |
_spec.ScanValues = _node.scanValues |
| 504 |
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { |
| 505 |
if _, ok := err.(*sqlgraph.NotFoundError); ok { |
| 506 |
err = &NotFoundError{subject.Label} |
| 507 |
} else if sqlgraph.IsConstraintError(err) { |
| 508 |
err = &ConstraintError{msg: err.Error(), wrap: err} |
| 509 |
} |
| 510 |
return nil, err |
| 511 |
} |
| 512 |
_u.mutation.done = true |
| 513 |
return _node, nil |
| 514 |
} |