MCPcopy Create free account
hub / github.com/Comfy-Org/registry-backend / sqlSave

Method sqlSave

ent/storagefile_update.go:192–239  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

190}
191
192func (sfu *StorageFileUpdate) sqlSave(ctx context.Context) (n int, err error) {
193 if err := sfu.check(); err != nil {
194 return n, err
195 }
196 _spec := sqlgraph.NewUpdateSpec(storagefile.Table, storagefile.Columns, sqlgraph.NewFieldSpec(storagefile.FieldID, field.TypeUUID))
197 if ps := sfu.mutation.predicates; len(ps) > 0 {
198 _spec.Predicate = func(selector *sql.Selector) {
199 for i := range ps {
200 ps[i](selector)
201 }
202 }
203 }
204 if value, ok := sfu.mutation.UpdateTime(); ok {
205 _spec.SetField(storagefile.FieldUpdateTime, field.TypeTime, value)
206 }
207 if value, ok := sfu.mutation.BucketName(); ok {
208 _spec.SetField(storagefile.FieldBucketName, field.TypeString, value)
209 }
210 if value, ok := sfu.mutation.ObjectName(); ok {
211 _spec.SetField(storagefile.FieldObjectName, field.TypeString, value)
212 }
213 if sfu.mutation.ObjectNameCleared() {
214 _spec.ClearField(storagefile.FieldObjectName, field.TypeString)
215 }
216 if value, ok := sfu.mutation.FilePath(); ok {
217 _spec.SetField(storagefile.FieldFilePath, field.TypeString, value)
218 }
219 if value, ok := sfu.mutation.FileType(); ok {
220 _spec.SetField(storagefile.FieldFileType, field.TypeString, value)
221 }
222 if value, ok := sfu.mutation.FileURL(); ok {
223 _spec.SetField(storagefile.FieldFileURL, field.TypeString, value)
224 }
225 if sfu.mutation.FileURLCleared() {
226 _spec.ClearField(storagefile.FieldFileURL, field.TypeString)
227 }
228 _spec.AddModifiers(sfu.modifiers...)
229 if n, err = sqlgraph.UpdateNodes(ctx, sfu.driver, _spec); err != nil {
230 if _, ok := err.(*sqlgraph.NotFoundError); ok {
231 err = &NotFoundError{storagefile.Label}
232 } else if sqlgraph.IsConstraintError(err) {
233 err = &ConstraintError{msg: err.Error(), wrap: err}
234 }
235 return 0, err
236 }
237 sfu.mutation.done = true
238 return n, nil
239}
240
241// StorageFileUpdateOne is the builder for updating a single StorageFile entity.
242type StorageFileUpdateOne struct {

Callers

nothing calls this directly

Calls 12

checkMethod · 0.95
BucketNameMethod · 0.80
ObjectNameMethod · 0.80
ObjectNameClearedMethod · 0.80
FilePathMethod · 0.80
FileTypeMethod · 0.80
FileURLMethod · 0.80
FileURLClearedMethod · 0.80
ErrorMethod · 0.65
UpdateTimeMethod · 0.45
SetFieldMethod · 0.45
ClearFieldMethod · 0.45

Tested by

no test coverage detected