This commit is contained in:
Daniel
2025-03-31 16:39:24 +08:00
parent 566c90cbba
commit 536aa39f95
5 changed files with 301 additions and 150 deletions

View File

@@ -1518,6 +1518,17 @@ func SQLTemplateFuncs(templateFuncMap *template.FuncMap) {
retBlocks = SelectBlocksRawStmt(stmt, 1, 512)
return
}
(*templateFuncMap)["getBlock"] = func(arg any) (retBlock *Block) {
switch v := arg.(type) {
case string:
retBlock = GetBlock(v)
case map[string]interface{}:
if id, ok := v["id"]; ok {
retBlock = GetBlock(id.(string))
}
}
return
}
(*templateFuncMap)["querySpans"] = func(stmt string, args ...string) (retSpans []*Span) {
for _, arg := range args {
stmt = strings.Replace(stmt, "?", arg, 1)