MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / resolveByDB

Function resolveByDB

core/middleware/operation.go:335–353  ·  view source on GitHub ↗
(dbItem *gorm.DB, values map[string]interface{}, beforeFunctions []functionInfo)

Source from the content-addressed store, hash-verified

333}
334
335func resolveByDB(dbItem *gorm.DB, values map[string]interface{}, beforeFunctions []functionInfo) {
336 for _, funcs := range beforeFunctions {
337 for key, value := range values {
338 if funcs.InputValue != key {
339 continue
340 }
341 var names []string
342 if funcs.IsList {
343 sql := fmt.Sprintf("SELECT %s FROM %s where %s in (?);", funcs.OutputColumn, funcs.DB, funcs.InputColumn)
344 _ = dbItem.Raw(sql, value).Scan(&names)
345 } else {
346 sql := fmt.Sprintf("select %s from %s where %s = ?;", funcs.OutputColumn, funcs.DB, funcs.InputColumn)
347 _ = dbItem.Raw(sql, value).Scan(&names)
348 }
349 values[funcs.OutputValue] = strings.Join(names, ",")
350 break
351 }
352 }
353}
354
355func replaceStr(val string, rep ...string) string {
356 for _, item := range rep {

Callers 1

OperationLogFunction · 0.85

Calls 1

ScanMethod · 0.65

Tested by

no test coverage detected