MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / pluginCatalog

Function pluginCatalog

internal/cmd/shim.go:62–134  ·  view source on GitHub ↗
(c *catalog.Catalog)

Source from the content-addressed store, hash-verified

60}
61
62func pluginCatalog(c *catalog.Catalog) *plugin.Catalog {
63 var schemas []*plugin.Schema
64 for _, s := range c.Schemas {
65 var enums []*plugin.Enum
66 var cts []*plugin.CompositeType
67 for _, typ := range s.Types {
68 switch typ := typ.(type) {
69 case *catalog.Enum:
70 enums = append(enums, &plugin.Enum{
71 Name: typ.Name,
72 Comment: typ.Comment,
73 Vals: typ.Vals,
74 })
75 case *catalog.CompositeType:
76 cts = append(cts, &plugin.CompositeType{
77 Name: typ.Name,
78 Comment: typ.Comment,
79 })
80 }
81 }
82 var tables []*plugin.Table
83 for _, t := range s.Tables {
84 var columns []*plugin.Column
85 for _, c := range t.Columns {
86 l := -1
87 if c.Length != nil {
88 l = *c.Length
89 }
90 columns = append(columns, &plugin.Column{
91 Name: c.Name,
92 Type: &plugin.Identifier{
93 Catalog: c.Type.Catalog,
94 Schema: c.Type.Schema,
95 Name: c.Type.Name,
96 },
97 Comment: c.Comment,
98 NotNull: c.IsNotNull,
99 Unsigned: c.IsUnsigned,
100 IsArray: c.IsArray,
101 ArrayDims: int32(c.ArrayDims),
102 Length: int32(l),
103 Table: &plugin.Identifier{
104 Catalog: t.Rel.Catalog,
105 Schema: t.Rel.Schema,
106 Name: t.Rel.Name,
107 },
108 })
109 }
110 tables = append(tables, &plugin.Table{
111 Rel: &plugin.Identifier{
112 Catalog: t.Rel.Catalog,
113 Schema: t.Rel.Schema,
114 Name: t.Rel.Name,
115 },
116 Columns: columns,
117 Comment: t.Comment,
118 })
119 }

Callers 1

codeGenRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected