MCPcopy Index your code
hub / github.com/coder/coder / SQLString

Method SQLString

coderd/rbac/regosql/sqltypes/array.go:46–62  ·  view source on GitHub ↗
(cfg *SQLGenerator)

Source from the content-addressed store, hash-verified

44}
45
46func (a ASTArray) SQLString(cfg *SQLGenerator) string {
47 switch a.MyType().UseAs().(type) {
48 case invalidNode:
49 cfg.AddError(xerrors.Errorf("array %q: empty array", a.Source))
50 return "ArrayError"
51 case AstNumber, AstString, AstBoolean:
52 // Primitive types
53 values := make([]string, 0, len(a.Value))
54 for _, v := range a.Value {
55 values = append(values, v.SQLString(cfg))
56 }
57 return fmt.Sprintf("ARRAY [%s]", strings.Join(values, ","))
58 }
59
60 cfg.AddError(xerrors.Errorf("array %q: unsupported type %T", a.Source, a.MyType()))
61 return "ArrayError"
62}
63
64func (a ASTArray) MyType() Node {
65 if len(a.Value) == 0 {

Callers 1

ContainsSQLMethod · 0.95

Calls 5

MyTypeMethod · 0.95
UseAsMethod · 0.65
AddErrorMethod · 0.65
SQLStringMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected