Skip to content

Commit b059471

Browse files
committed
refactor: update ModelName function to handle schema name (main)
1 parent 034ef19 commit b059471

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

internal/core/utils.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import (
66
"strings"
77
)
88

9-
func ModelName(name string) string {
9+
func ModelName(enumName string, schemaName string) string {
10+
if schemaName != "" {
11+
enumName = schemaName + "_" + enumName
12+
}
1013
out := ""
11-
for _, p := range strings.Split(name, "_") {
14+
for _, p := range strings.Split(enumName, "_") {
1215
out += cases.Title(language.Und, cases.NoLower).String(p)
1316
}
1417
return out

internal/types/postgresql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ func PostgresTypeToPython(req *plugin.GenerateRequest, col *plugin.Column) strin
5151
for _, enum := range schema.Enums {
5252
if columnType == enum.Name {
5353
if schema.Name == req.Catalog.DefaultSchema {
54-
return "models." + core.ModelName(enum.Name)
54+
return "models." + core.ModelName(enum.Name, "")
5555
}
56-
return "models." + core.ModelName(schema.Name+"_"+enum.Name)
56+
return "models." + core.ModelName(enum.Name, schema.Name)
5757
}
5858
}
5959
}

0 commit comments

Comments
 (0)