MCPcopy
hub / github.com/cloudreve/cloudreve / sqlSave

Method sqlSave

ent/file_update.go:1347–1737  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1345}
1346
1347func (fuo *FileUpdateOne) sqlSave(ctx context.Context) (_node *File, err error) {
1348 if err := fuo.check(); err != nil {
1349 return _node, err
1350 }
1351 _spec := sqlgraph.NewUpdateSpec(file.Table, file.Columns, sqlgraph.NewFieldSpec(file.FieldID, field.TypeInt))
1352 id, ok := fuo.mutation.ID()
1353 if !ok {
1354 return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "File.id" for update`)}
1355 }
1356 _spec.Node.ID.Value = id
1357 if fields := fuo.fields; len(fields) > 0 {
1358 _spec.Node.Columns = make([]string, 0, len(fields))
1359 _spec.Node.Columns = append(_spec.Node.Columns, file.FieldID)
1360 for _, f := range fields {
1361 if !file.ValidColumn(f) {
1362 return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
1363 }
1364 if f != file.FieldID {
1365 _spec.Node.Columns = append(_spec.Node.Columns, f)
1366 }
1367 }
1368 }
1369 if ps := fuo.mutation.predicates; len(ps) > 0 {
1370 _spec.Predicate = func(selector *sql.Selector) {
1371 for i := range ps {
1372 ps[i](selector)
1373 }
1374 }
1375 }
1376 if value, ok := fuo.mutation.UpdatedAt(); ok {
1377 _spec.SetField(file.FieldUpdatedAt, field.TypeTime, value)
1378 }
1379 if value, ok := fuo.mutation.GetType(); ok {
1380 _spec.SetField(file.FieldType, field.TypeInt, value)
1381 }
1382 if value, ok := fuo.mutation.AddedType(); ok {
1383 _spec.AddField(file.FieldType, field.TypeInt, value)
1384 }
1385 if value, ok := fuo.mutation.Name(); ok {
1386 _spec.SetField(file.FieldName, field.TypeString, value)
1387 }
1388 if value, ok := fuo.mutation.Size(); ok {
1389 _spec.SetField(file.FieldSize, field.TypeInt64, value)
1390 }
1391 if value, ok := fuo.mutation.AddedSize(); ok {
1392 _spec.AddField(file.FieldSize, field.TypeInt64, value)
1393 }
1394 if value, ok := fuo.mutation.PrimaryEntity(); ok {
1395 _spec.SetField(file.FieldPrimaryEntity, field.TypeInt, value)
1396 }
1397 if value, ok := fuo.mutation.AddedPrimaryEntity(); ok {
1398 _spec.AddField(file.FieldPrimaryEntity, field.TypeInt, value)
1399 }
1400 if fuo.mutation.PrimaryEntityCleared() {
1401 _spec.ClearField(file.FieldPrimaryEntity, field.TypeInt)
1402 }
1403 if value, ok := fuo.mutation.IsSymbolic(); ok {
1404 _spec.SetField(file.FieldIsSymbolic, field.TypeBool, value)

Callers

nothing calls this directly

Calls 15

checkMethod · 0.95
ValidColumnFunction · 0.92
AddedPrimaryEntityMethod · 0.80
PrimaryEntityClearedMethod · 0.80
ParentClearedMethod · 0.80
ParentIDsMethod · 0.80
ChildrenClearedMethod · 0.80
RemovedChildrenIDsMethod · 0.80
ChildrenIDsMethod · 0.80
MetadataClearedMethod · 0.80
RemovedMetadataIDsMethod · 0.80
MetadataIDsMethod · 0.80

Tested by

no test coverage detected