MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / sqlSave

Method sqlSave

ent/storagepolicy_create.go:341–357  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

339}
340
341func (spc *StoragePolicyCreate) sqlSave(ctx context.Context) (*StoragePolicy, error) {
342 if err := spc.check(); err != nil {
343 return nil, err
344 }
345 _node, _spec := spc.createSpec()
346 if err := sqlgraph.CreateNode(ctx, spc.driver, _spec); err != nil {
347 if sqlgraph.IsConstraintError(err) {
348 err = &ConstraintError{msg: err.Error(), wrap: err}
349 }
350 return nil, err
351 }
352 id := _spec.ID.Value.(int64)
353 _node.ID = int(id)
354 spc.mutation.id = &_node.ID
355 spc.mutation.done = true
356 return _node, nil
357}
358
359func (spc *StoragePolicyCreate) createSpec() (*StoragePolicy, *sqlgraph.CreateSpec) {
360 var (

Callers

nothing calls this directly

Calls 3

checkMethod · 0.95
createSpecMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected