MCPcopy
hub / github.com/sqlc-dev/sqlc / isNamedParam

Method isNamedParam

internal/sql/ast/a_expr.go:19–34  ·  view source on GitHub ↗

isNamedParam returns true if this A_Expr represents a named parameter (@name) and extracts the parameter name if so.

()

Source from the content-addressed store, hash-verified

17// isNamedParam returns true if this A_Expr represents a named parameter (@name)
18// and extracts the parameter name if so.
19func (n *A_Expr) isNamedParam() (string, bool) {
20 if n.Name == nil || len(n.Name.Items) != 1 {
21 return "", false
22 }
23 s, ok := n.Name.Items[0].(*String)
24 if !ok || s.Str != "@" {
25 return "", false
26 }
27 if set(n.Lexpr) || !set(n.Rexpr) {
28 return "", false
29 }
30 if nameStr, ok := n.Rexpr.(*String); ok {
31 return nameStr.Str, true
32 }
33 return "", false
34}
35
36func (n *A_Expr) Format(buf *TrackedBuffer, d format.Dialect) {
37 if n == nil {

Callers 1

FormatMethod · 0.95

Calls 1

setFunction · 0.85

Tested by

no test coverage detected