@@ -3,6 +3,7 @@ package cmd
33import (
44 "strings"
55
6+ goopts "github.com/sqlc-dev/sqlc/internal/codegen/golang/opts"
67 "github.com/sqlc-dev/sqlc/internal/compiler"
78 "github.com/sqlc-dev/sqlc/internal/config"
89 "github.com/sqlc-dev/sqlc/internal/config/convert"
@@ -11,7 +12,7 @@ import (
1112 "github.com/sqlc-dev/sqlc/internal/sql/catalog"
1213)
1314
14- func pluginOverride (r * compiler.Result , o config.Override ) * plugin .Override {
15+ func pluginOverride (r * compiler.Result , o config.Override ) goopts .Override {
1516 var column string
1617 var table plugin.Identifier
1718
@@ -33,7 +34,7 @@ func pluginOverride(r *compiler.Result, o config.Override) *plugin.Override {
3334 column = colParts [3 ]
3435 }
3536 }
36- return & plugin .Override {
37+ return goopts .Override {
3738 CodeType : "" , // FIXME
3839 DbType : o .DBType ,
3940 Nullable : o .Nullable ,
@@ -46,18 +47,13 @@ func pluginOverride(r *compiler.Result, o config.Override) *plugin.Override {
4647}
4748
4849func pluginSettings (r * compiler.Result , cs config.CombinedSettings ) * plugin.Settings {
49- var over []* plugin.Override
50- for _ , o := range cs .Overrides {
51- over = append (over , pluginOverride (r , o ))
52- }
5350 return & plugin.Settings {
54- Version : cs .Global .Version ,
55- Engine : string (cs .Package .Engine ),
56- Schema : []string (cs .Package .Schema ),
57- Queries : []string (cs .Package .Queries ),
58- Overrides : over ,
59- Rename : cs .Rename ,
60- Codegen : pluginCodegen (cs , cs .Codegen ),
51+ Version : cs .Global .Version ,
52+ Engine : string (cs .Package .Engine ),
53+ Schema : []string (cs .Package .Schema ),
54+ Queries : []string (cs .Package .Queries ),
55+ Rename : cs .Rename ,
56+ Codegen : pluginCodegen (cs , cs .Codegen ),
6157 }
6258}
6359
@@ -101,12 +97,12 @@ func pluginWASM(p config.Plugin) *plugin.Codegen_WASM {
10197 return nil
10298}
10399
104- func pluginGoType (o config.Override ) * plugin .ParsedGoType {
100+ func pluginGoType (o config.Override ) * goopts .ParsedGoType {
105101 // Note that there is a slight mismatch between this and the
106102 // proto api. The GoType on the override is the unparsed type,
107103 // which could be a qualified path or an object, as per
108104 // https://docs.sqlc.dev/en/v1.18.0/reference/config.html#type-overriding
109- return & plugin .ParsedGoType {
105+ return & goopts .ParsedGoType {
110106 ImportPath : o .GoImportPath ,
111107 Package : o .GoPackage ,
112108 TypeName : o .GoTypeName ,
@@ -115,6 +111,46 @@ func pluginGoType(o config.Override) *plugin.ParsedGoType {
115111 }
116112}
117113
114+ func pluginGoOpts (sqlGo * config.SQLGo , cs config.CombinedSettings , r * compiler.Result ) * goopts.Options {
115+ var overrides []goopts.Override
116+ for _ , o := range cs .Overrides {
117+ overrides = append (overrides , pluginOverride (r , o ))
118+ }
119+ return & goopts.Options {
120+ EmitInterface : sqlGo .EmitInterface ,
121+ EmitJsonTags : sqlGo .EmitJSONTags ,
122+ JsonTagsIdUppercase : sqlGo .JsonTagsIDUppercase ,
123+ EmitDbTags : sqlGo .EmitDBTags ,
124+ EmitPreparedQueries : sqlGo .EmitPreparedQueries ,
125+ EmitExactTableNames : sqlGo .EmitExactTableNames ,
126+ EmitEmptySlices : sqlGo .EmitEmptySlices ,
127+ EmitExportedQueries : sqlGo .EmitExportedQueries ,
128+ EmitResultStructPointers : sqlGo .EmitResultStructPointers ,
129+ EmitParamsStructPointers : sqlGo .EmitParamsStructPointers ,
130+ EmitMethodsWithDbArgument : sqlGo .EmitMethodsWithDBArgument ,
131+ EmitPointersForNullTypes : sqlGo .EmitPointersForNullTypes ,
132+ EmitEnumValidMethod : sqlGo .EmitEnumValidMethod ,
133+ EmitAllEnumValues : sqlGo .EmitAllEnumValues ,
134+ JsonTagsCaseStyle : sqlGo .JSONTagsCaseStyle ,
135+ Package : sqlGo .Package ,
136+ Out : sqlGo .Out ,
137+ Overrides : overrides ,
138+ // Rename intentionally omitted
139+ SqlPackage : sqlGo .SQLPackage ,
140+ SqlDriver : sqlGo .SQLDriver ,
141+ OutputBatchFileName : sqlGo .OutputBatchFileName ,
142+ OutputDbFileName : sqlGo .OutputDBFileName ,
143+ OutputModelsFileName : sqlGo .OutputModelsFileName ,
144+ OutputQuerierFileName : sqlGo .OutputQuerierFileName ,
145+ OutputCopyfromFileName : sqlGo .OutputCopyFromFileName ,
146+ OutputFilesSuffix : sqlGo .OutputFilesSuffix ,
147+ InflectionExcludeTableNames : sqlGo .InflectionExcludeTableNames ,
148+ QueryParameterLimit : sqlGo .QueryParameterLimit ,
149+ OmitUnusedStructs : sqlGo .OmitUnusedStructs ,
150+ BuildTags : sqlGo .BuildTags ,
151+ }
152+ }
153+
118154func pluginCatalog (c * catalog.Catalog ) * plugin.Catalog {
119155 var schemas []* plugin.Schema
120156 for _ , s := range c .Schemas {
0 commit comments