MCPcopy Create free account
hub / github.com/cel-expr/cel-go / maybeQuoteIdent

Method maybeQuoteIdent

parser/unparser.go:73–94  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

71var identifierPartPattern *regexp.Regexp = regexp.MustCompile(`^[A-Za-z_][0-9A-Za-z_]*$`)
72
73func (un *unparser) maybeQuoteIdent(name string) string {
74 if !un.options.escapeIdentifiers {
75 return name
76 }
77 if name == "" {
78 return ""
79 }
80 if strings.HasPrefix(name, ".") {
81 return "." + un.maybeQuoteIdent(name[1:])
82 }
83 if strings.Contains(name, ".") {
84 parts := strings.Split(name, ".")
85 for i, part := range parts {
86 parts[i] = un.maybeQuoteIdent(part)
87 }
88 return strings.Join(parts, ".")
89 }
90 if !identifierPartPattern.MatchString(name) || isReservedIdent(name) {
91 return "`" + name + "`"
92 }
93 return name
94}
95
96func (un *unparser) maybeQuoteFunction(fun string) string {
97 return un.maybeQuoteIdent(fun)

Callers 3

maybeQuoteFunctionMethod · 0.95
visitCallFuncMethod · 0.95
visitIdentMethod · 0.95

Calls 2

isReservedIdentFunction · 0.85
ContainsMethod · 0.65

Tested by

no test coverage detected