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

Method sqlQuery

ent/storagefile_query.go:422–455  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

420}
421
422func (sfq *StorageFileQuery) sqlQuery(ctx context.Context) *sql.Selector {
423 builder := sql.Dialect(sfq.driver.Dialect())
424 t1 := builder.Table(storagefile.Table)
425 columns := sfq.ctx.Fields
426 if len(columns) == 0 {
427 columns = storagefile.Columns
428 }
429 selector := builder.Select(t1.Columns(columns...)...).From(t1)
430 if sfq.sql != nil {
431 selector = sfq.sql
432 selector.Select(selector.Columns(columns...)...)
433 }
434 if sfq.ctx.Unique != nil && *sfq.ctx.Unique {
435 selector.Distinct()
436 }
437 for _, m := range sfq.modifiers {
438 m(selector)
439 }
440 for _, p := range sfq.predicates {
441 p(selector)
442 }
443 for _, p := range sfq.order {
444 p(selector)
445 }
446 if offset := sfq.ctx.Offset; offset != nil {
447 // limit is mandatory for offset clause. We start
448 // with default value, and override it below if needed.
449 selector.Offset(*offset).Limit(math.MaxInt32)
450 }
451 if limit := sfq.ctx.Limit; limit != nil {
452 selector.Limit(*limit)
453 }
454 return selector
455}
456
457// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
458// updated, deleted or "selected ... for update" by other sessions, until the transaction is

Callers 2

sqlScanMethod · 0.45
sqlScanMethod · 0.45

Calls 4

DialectMethod · 0.80
SelectMethod · 0.45
LimitMethod · 0.45
OffsetMethod · 0.45

Tested by

no test coverage detected