@@ -10,8 +10,8 @@ import (
1010"sort"
1111"strings"
1212
13- "buf.build/gen/go/sqlc/sqlc/protocolbuffers/go/protos/plugin"
1413"github.com/sqlc-dev/sqlc-go/metadata"
14+ "github.com/sqlc-dev/sqlc-go/plugin"
1515"github.com/sqlc-dev/sqlc-go/sdk"
1616
1717pyast "github.com/sqlc-dev/sqlc-gen-python/internal/ast"
@@ -180,7 +180,7 @@ func (q Query) ArgDictNode() *pyast.Node {
180180}
181181}
182182
183- func makePyType (req * plugin.CodeGenRequest , col * plugin.Column ) pyType {
183+ func makePyType (req * plugin.GenerateRequest , col * plugin.Column ) pyType {
184184typ := pyInnerType (req , col )
185185return pyType {
186186InnerType : typ ,
@@ -189,21 +189,7 @@ func makePyType(req *plugin.CodeGenRequest, col *plugin.Column) pyType {
189189}
190190}
191191
192- func pyInnerType (req * plugin.CodeGenRequest , col * plugin.Column ) string {
193- columnType := sdk .DataType (col .Type )
194- for _ , oride := range req .Settings .Overrides {
195- if ! pyTypeIsSet (oride ) {
196- continue
197- }
198- sameTable := sdk .Matches (oride , col .Table , req .Catalog .DefaultSchema )
199- if oride .Column != "" && sdk .MatchString (oride .ColumnName , col .Name ) && sameTable {
200- return oride .CodeType
201- }
202- if oride .DbType != "" && oride .DbType == columnType && oride .Nullable != (col .NotNull || col .IsArray ) {
203- return oride .CodeType
204- }
205- }
206-
192+ func pyInnerType (req * plugin.GenerateRequest , col * plugin.Column ) string {
207193switch req .Settings .Engine {
208194case "postgresql" :
209195return postgresType (req , col )
@@ -214,9 +200,6 @@ func pyInnerType(req *plugin.CodeGenRequest, col *plugin.Column) string {
214200}
215201
216202func modelName (name string , settings * plugin.Settings ) string {
217- if rename := settings .Rename [name ]; rename != "" {
218- return rename
219- }
220203out := ""
221204for _ , p := range strings .Split (name , "_" ) {
222205out += strings .Title (p )
@@ -243,7 +226,7 @@ func pyEnumValueName(value string) string {
243226return strings .ToUpper (id )
244227}
245228
246- func buildEnums (req * plugin.CodeGenRequest ) []Enum {
229+ func buildEnums (req * plugin.GenerateRequest ) []Enum {
247230var enums []Enum
248231for _ , schema := range req .Catalog .Schemas {
249232if schema .Name == "pg_catalog" || schema .Name == "information_schema" {
@@ -276,7 +259,7 @@ func buildEnums(req *plugin.CodeGenRequest) []Enum {
276259return enums
277260}
278261
279- func buildModels (conf Config , req * plugin.CodeGenRequest ) []Struct {
262+ func buildModels (conf Config , req * plugin.GenerateRequest ) []Struct {
280263var structs []Struct
281264for _ , schema := range req .Catalog .Schemas {
282265if schema .Name == "pg_catalog" || schema .Name == "information_schema" {
@@ -338,7 +321,7 @@ type pyColumn struct {
338321* plugin.Column
339322}
340323
341- func columnsToStruct (req * plugin.CodeGenRequest , name string , columns []pyColumn ) * Struct {
324+ func columnsToStruct (req * plugin.GenerateRequest , name string , columns []pyColumn ) * Struct {
342325gs := Struct {
343326Name : name ,
344327}
@@ -380,7 +363,7 @@ func sqlalchemySQL(s, engine string) string {
380363return s
381364}
382365
383- func buildQueries (conf Config , req * plugin.CodeGenRequest , structs []Struct ) ([]Query , error ) {
366+ func buildQueries (conf Config , req * plugin.GenerateRequest , structs []Struct ) ([]Query , error ) {
384367qs := make ([]Query , 0 , len (req .Queries ))
385368for _ , query := range req .Queries {
386369if query .Name == "" {
@@ -1091,7 +1074,7 @@ func HashComment(s string) string {
10911074return "# " + strings .ReplaceAll (s , "\n " , "\n # " )
10921075}
10931076
1094- func Generate (_ context.Context , req * plugin.CodeGenRequest ) (* plugin.CodeGenResponse , error ) {
1077+ func Generate (_ context.Context , req * plugin.GenerateRequest ) (* plugin.GenerateResponse , error ) {
10951078var conf Config
10961079if len (req .PluginOptions ) > 0 {
10971080if err := json .Unmarshal (req .PluginOptions , & conf ); err != nil {
@@ -1107,11 +1090,10 @@ func Generate(_ context.Context, req *plugin.CodeGenRequest) (*plugin.CodeGenRes
11071090}
11081091
11091092i := & importer {
1110- Settings : req .Settings ,
1111- Models : models ,
1112- Queries : queries ,
1113- Enums : enums ,
1114- C : conf ,
1093+ Models : models ,
1094+ Queries : queries ,
1095+ Enums : enums ,
1096+ C : conf ,
11151097}
11161098
11171099tctx := pyTmplCtx {
@@ -1143,7 +1125,7 @@ func Generate(_ context.Context, req *plugin.CodeGenRequest) (*plugin.CodeGenRes
11431125output [name ] = string (result .Python )
11441126}
11451127
1146- resp := plugin.CodeGenResponse {}
1128+ resp := plugin.GenerateResponse {}
11471129
11481130for filename , code := range output {
11491131resp .Files = append (resp .Files , & plugin.File {
0 commit comments