@@ -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
1717 pyast "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 {
184184 typ := pyInnerType (req , col )
185185 return pyType {
186186 InnerType : 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 {
207193 switch req .Settings .Engine {
208194 case "postgresql" :
209195 return 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- }
220203 out := ""
221204 for _ , p := range strings .Split (name , "_" ) {
222205 out += strings .Title (p )
@@ -243,7 +226,7 @@ func pyEnumValueName(value string) string {
243226 return strings .ToUpper (id )
244227}
245228
246- func buildEnums (req * plugin.CodeGenRequest ) []Enum {
229+ func buildEnums (req * plugin.GenerateRequest ) []Enum {
247230 var enums []Enum
248231 for _ , schema := range req .Catalog .Schemas {
249232 if schema .Name == "pg_catalog" || schema .Name == "information_schema" {
@@ -276,7 +259,7 @@ func buildEnums(req *plugin.CodeGenRequest) []Enum {
276259 return enums
277260}
278261
279- func buildModels (conf Config , req * plugin.CodeGenRequest ) []Struct {
262+ func buildModels (conf Config , req * plugin.GenerateRequest ) []Struct {
280263 var structs []Struct
281264 for _ , schema := range req .Catalog .Schemas {
282265 if 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 {
342325 gs := Struct {
343326 Name : name ,
344327 }
@@ -380,7 +363,7 @@ func sqlalchemySQL(s, engine string) string {
380363 return 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 ) {
384367 qs := make ([]Query , 0 , len (req .Queries ))
385368 for _ , query := range req .Queries {
386369 if query .Name == "" {
@@ -1091,7 +1074,7 @@ func HashComment(s string) string {
10911074 return "# " + 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 ) {
10951078 var conf Config
10961079 if len (req .PluginOptions ) > 0 {
10971080 if err := json .Unmarshal (req .PluginOptions , & conf ); err != nil {
@@ -1107,11 +1090,10 @@ func Generate(_ context.Context, req *plugin.CodeGenRequest) (*plugin.CodeGenRes
11071090 }
11081091
11091092 i := & 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
11171099 tctx := pyTmplCtx {
@@ -1143,7 +1125,7 @@ func Generate(_ context.Context, req *plugin.CodeGenRequest) (*plugin.CodeGenRes
11431125 output [name ] = string (result .Python )
11441126 }
11451127
1146- resp := plugin.CodeGenResponse {}
1128+ resp := plugin.GenerateResponse {}
11471129
11481130 for filename , code := range output {
11491131 resp .Files = append (resp .Files , & plugin.File {
0 commit comments