MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / sqlSave

Method sqlSave

ent/entity_update.go:338–505  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

336}
337
338func (eu *EntityUpdate) sqlSave(ctx context.Context) (n int, err error) {
339 if err := eu.check(); err != nil {
340 return n, err
341 }
342 _spec := sqlgraph.NewUpdateSpec(entity.Table, entity.Columns, sqlgraph.NewFieldSpec(entity.FieldID, field.TypeInt))
343 if ps := eu.mutation.predicates; len(ps) > 0 {
344 _spec.Predicate = func(selector *sql.Selector) {
345 for i := range ps {
346 ps[i](selector)
347 }
348 }
349 }
350 if value, ok := eu.mutation.UpdatedAt(); ok {
351 _spec.SetField(entity.FieldUpdatedAt, field.TypeTime, value)
352 }
353 if value, ok := eu.mutation.DeletedAt(); ok {
354 _spec.SetField(entity.FieldDeletedAt, field.TypeTime, value)
355 }
356 if eu.mutation.DeletedAtCleared() {
357 _spec.ClearField(entity.FieldDeletedAt, field.TypeTime)
358 }
359 if value, ok := eu.mutation.GetType(); ok {
360 _spec.SetField(entity.FieldType, field.TypeInt, value)
361 }
362 if value, ok := eu.mutation.AddedType(); ok {
363 _spec.AddField(entity.FieldType, field.TypeInt, value)
364 }
365 if value, ok := eu.mutation.Source(); ok {
366 _spec.SetField(entity.FieldSource, field.TypeString, value)
367 }
368 if value, ok := eu.mutation.Size(); ok {
369 _spec.SetField(entity.FieldSize, field.TypeInt64, value)
370 }
371 if value, ok := eu.mutation.AddedSize(); ok {
372 _spec.AddField(entity.FieldSize, field.TypeInt64, value)
373 }
374 if value, ok := eu.mutation.ReferenceCount(); ok {
375 _spec.SetField(entity.FieldReferenceCount, field.TypeInt, value)
376 }
377 if value, ok := eu.mutation.AddedReferenceCount(); ok {
378 _spec.AddField(entity.FieldReferenceCount, field.TypeInt, value)
379 }
380 if value, ok := eu.mutation.UploadSessionID(); ok {
381 _spec.SetField(entity.FieldUploadSessionID, field.TypeUUID, value)
382 }
383 if eu.mutation.UploadSessionIDCleared() {
384 _spec.ClearField(entity.FieldUploadSessionID, field.TypeUUID)
385 }
386 if value, ok := eu.mutation.Props(); ok {
387 _spec.SetField(entity.FieldProps, field.TypeJSON, value)
388 }
389 if eu.mutation.PropsCleared() {
390 _spec.ClearField(entity.FieldProps, field.TypeJSON)
391 }
392 if eu.mutation.FileCleared() {
393 edge := &sqlgraph.EdgeSpec{
394 Rel: sqlgraph.M2M,
395 Inverse: true,

Callers

nothing calls this directly

Calls 15

checkMethod · 0.95
AddedReferenceCountMethod · 0.80
RemovedFileIDsMethod · 0.80
UpdatedAtMethod · 0.65
SourceMethod · 0.65
SizeMethod · 0.65
ReferenceCountMethod · 0.65
UploadSessionIDMethod · 0.65
PropsMethod · 0.65
ErrorMethod · 0.65
SetFieldMethod · 0.45

Tested by

no test coverage detected