@@ -215,18 +215,18 @@ func makePyType(req *plugin.GenerateRequest, col *plugin.Column) pyType {
215215 }
216216
217217 // No override found, use the standard type mapping
218- typ := pyInnerType (req , col )
218+ typ := pyInnerType (conf , req , col )
219219 return pyType {
220220 InnerType : typ ,
221221 IsArray : col .IsArray ,
222222 IsNull : ! col .NotNull ,
223223 }
224224}
225225
226- func pyInnerType (req * plugin.GenerateRequest , col * plugin.Column ) string {
226+ func pyInnerType (conf Config , req * plugin.GenerateRequest , col * plugin.Column ) string {
227227 switch req .Settings .Engine {
228228 case "postgresql" :
229- return postgresType (req , col )
229+ return postgresType (conf , req , col )
230230 default :
231231 log .Println ("unsupported engine type" )
232232 return "Any"
@@ -260,18 +260,18 @@ func pyEnumValueName(value string) string {
260260 return strings .ToUpper (id )
261261}
262262
263- func buildEnums (req * plugin.GenerateRequest ) []Enum {
263+ func buildEnums (conf Config , req * plugin.GenerateRequest ) []Enum {
264264 var enums []Enum
265265 for _ , schema := range req .Catalog .Schemas {
266266 if schema .Name == "pg_catalog" || schema .Name == "information_schema" {
267267 continue
268268 }
269269 for _ , enum := range schema .Enums {
270270 var enumName string
271- if schema .Name == req .Catalog .DefaultSchema {
272- enumName = enum .Name
273- } else {
271+ if conf .EmitSchemaNamePrefix && schema .Name != req .Catalog .DefaultSchema {
274272 enumName = schema .Name + "_" + enum .Name
273+ } else {
274+ enumName = enum .Name
275275 }
276276 e := Enum {
277277 Name : modelName (enumName , req .Settings ),
@@ -301,10 +301,10 @@ func buildModels(conf Config, req *plugin.GenerateRequest) []Struct {
301301 }
302302 for _ , table := range schema .Tables {
303303 var tableName string
304- if schema .Name == req .Catalog .DefaultSchema {
305- tableName = table .Rel .Name
306- } else {
304+ if conf .EmitSchemaNamePrefix && schema .Name != req .Catalog .DefaultSchema {
307305 tableName = schema .Name + "_" + table .Rel .Name
306+ } else {
307+ tableName = table .Rel .Name
308308 }
309309 structName := tableName
310310 if ! conf .EmitExactTableNames {
@@ -1219,7 +1219,7 @@ func Generate(_ context.Context, req *plugin.GenerateRequest) (*plugin.GenerateR
12191219 }
12201220 }
12211221
1222- enums := buildEnums (req )
1222+ enums := buildEnums (conf , req )
12231223 models := buildModels (conf , req )
12241224 queries , err := buildQueries (conf , req , models )
12251225 if err != nil {
0 commit comments