@@ -39,6 +39,7 @@ func pluginOverride(o config.Override) *plugin.Override {
3939 ColumnName : column ,
4040 Table : & table ,
4141 PythonType : pluginPythonType (o .PythonType ),
42+ GoType : pluginGoType (o ),
4243 }
4344}
4445
@@ -56,6 +57,7 @@ func pluginSettings(cs config.CombinedSettings) *plugin.Settings {
5657 Rename : cs .Rename ,
5758 Python : pluginPythonCode (cs .Python ),
5859 Kotlin : pluginKotlinCode (cs .Kotlin ),
60+ Go : pluginGoCode (cs .Go ),
5961 }
6062}
6163
@@ -69,6 +71,42 @@ func pluginPythonCode(s config.SQLPython) *plugin.PythonCode {
6971 }
7072}
7173
74+ func pluginGoCode (s config.SQLGo ) * plugin.GoCode {
75+ return & plugin.GoCode {
76+ EmitInterface : s .EmitInterface ,
77+ EmitJsonTags : s .EmitJSONTags ,
78+ EmitDbTags : s .EmitDBTags ,
79+ EmitPreparedQueries : s .EmitPreparedQueries ,
80+ EmitExactTableNames : s .EmitExactTableNames ,
81+ EmitEmptySlices : s .EmitEmptySlices ,
82+ EmitExportedQueries : s .EmitExportedQueries ,
83+ EmitResultStructPointers : s .EmitResultStructPointers ,
84+ EmitParamsStructPointers : s .EmitParamsStructPointers ,
85+ EmitMethodsWithDbArgument : s .EmitMethodsWithDBArgument ,
86+ JsonTagsCaseStyle : s .JSONTagsCaseStyle ,
87+ Package : s .Package ,
88+ Out : s .Out ,
89+ SqlPackage : s .SQLPackage ,
90+ OutputDbFileName : s .OutputDBFileName ,
91+ OutputModelsFileName : s .OutputModelsFileName ,
92+ OutputQuerierFileName : s .OutputQuerierFileName ,
93+ OutputFilesSuffix : s .OutputFilesSuffix ,
94+ }
95+ }
96+
97+ func pluginGoType (o config.Override ) * plugin.ParsedGoType {
98+ // Note that there is a slight mismatch between this and the
99+ // proto api. The GoType on the override is the unparsed type,
100+ // which could be a qualified path or an object, as per
101+ // https://docs.sqlc.dev/en/latest/reference/config.html#renaming-struct-fields
102+ return & plugin.ParsedGoType {
103+ ImportPath : o .GoImportPath ,
104+ Package : o .GoPackage ,
105+ TypeName : o .GoTypeName ,
106+ BasicType : o .GoBasicType ,
107+ }
108+ }
109+
72110func pluginPythonType (pt config.PythonType ) * plugin.PythonType {
73111 return & plugin.PythonType {
74112 Module : pt .Module ,
@@ -88,16 +126,21 @@ func pluginCatalog(c *catalog.Catalog) *plugin.Catalog {
88126 var schemas []* plugin.Schema
89127 for _ , s := range c .Schemas {
90128 var enums []* plugin.Enum
129+ var cts []* plugin.CompositeType
91130 for _ , typ := range s .Types {
92- enum , ok := typ .(* catalog.Enum )
93- if ! ok {
94- continue
131+ switch typ := typ .(type ) {
132+ case * catalog.Enum :
133+ enums = append (enums , & plugin.Enum {
134+ Name : typ .Name ,
135+ Comment : typ .Comment ,
136+ Vals : typ .Vals ,
137+ })
138+ case * catalog.CompositeType :
139+ cts = append (cts , & plugin.CompositeType {
140+ Name : typ .Name ,
141+ Comment : typ .Comment ,
142+ })
95143 }
96- enums = append (enums , & plugin.Enum {
97- Name : enum .Name ,
98- Comment : enum .Comment ,
99- Vals : enum .Vals ,
100- })
101144 }
102145 var tables []* plugin.Table
103146 for _ , t := range s .Tables {
@@ -136,10 +179,11 @@ func pluginCatalog(c *catalog.Catalog) *plugin.Catalog {
136179 })
137180 }
138181 schemas = append (schemas , & plugin.Schema {
139- Comment : s .Comment ,
140- Name : s .Name ,
141- Tables : tables ,
142- Enums : enums ,
182+ Comment : s .Comment ,
183+ Name : s .Name ,
184+ Tables : tables ,
185+ Enums : enums ,
186+ CompositeTypes : cts ,
143187 })
144188 }
145189 return & plugin.Catalog {
@@ -161,14 +205,23 @@ func pluginQueries(r *compiler.Result) []*plugin.Query {
161205 for _ , p := range q .Params {
162206 params = append (params , pluginQueryParam (p ))
163207 }
208+ var iit * plugin.Identifier
209+ if q .InsertIntoTable != nil {
210+ iit = & plugin.Identifier {
211+ Catalog : q .InsertIntoTable .Catalog ,
212+ Schema : q .InsertIntoTable .Schema ,
213+ Name : q .InsertIntoTable .Name ,
214+ }
215+ }
164216 out = append (out , & plugin.Query {
165- Name : q .Name ,
166- Cmd : q .Cmd ,
167- Text : q .SQL ,
168- Comments : q .Comments ,
169- Columns : columns ,
170- Params : params ,
171- Filename : q .Filename ,
217+ Name : q .Name ,
218+ Cmd : q .Cmd ,
219+ Text : q .SQL ,
220+ Comments : q .Comments ,
221+ Columns : columns ,
222+ Params : params ,
223+ Filename : q .Filename ,
224+ InsertIntoTable : iit ,
172225 })
173226 }
174227 return out
@@ -180,11 +233,13 @@ func pluginQueryColumn(c *compiler.Column) *plugin.Column {
180233 l = * c .Length
181234 }
182235 out := & plugin.Column {
183- Name : c .Name ,
184- Comment : c .Comment ,
185- NotNull : c .NotNull ,
186- IsArray : c .IsArray ,
187- Length : int32 (l ),
236+ Name : c .Name ,
237+ Comment : c .Comment ,
238+ NotNull : c .NotNull ,
239+ IsArray : c .IsArray ,
240+ Length : int32 (l ),
241+ IsNamedParam : c .IsNamedParam ,
242+ IsFuncCall : c .IsFuncCall ,
188243 }
189244
190245 if c .Type != nil {
0 commit comments