8000 db_models for enums · cortea-ai/sqlc-gen-python@9a37c21 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a37c21

Browse files
committed
db_models for enums
1 parent e58342d commit 9a37c21

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

internal/gen.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ func buildModels(conf Config, req *plugin.GenerateRequest) []Struct {
446446
}
447447
for _, column := range table.Columns {
448448
typ := makePyType(conf, req, column) // TODO: This used to call compiler.ConvertColumn?
449-
typ.InnerType = strings.TrimPrefix(typ.InnerType, "models.")
449+
typ.InnerType = strings.TrimPrefix(typ.InnerType, "db_models.")
450450
s.Fields = append(s.Fields, Field{
451451
Name: column.Name,
452452
Type: typ,
@@ -692,9 +692,9 @@ func buildQueries(conf Config, req *plugin.GenerateRequest, structs []Struct) ([
692692
same := true
693693
for i, f := range s.Fields {
694694
c := query.Columns[i]
695-
// HACK: models do not have "models." on their types, so trim that so we can find matches
695+
// HACK: models do not have "db_models." on their types, so trim that so we can find matches
696696
trimmedPyType := makePyType(conf, req, c)
697-
trimmedPyType.InnerType = strings.TrimPrefix(trimmedPyType.InnerType, "models.")
697+
trimmedPyType.InnerType = strings.TrimPrefix(trimmedPyType.InnerType, "db_models.")
698698
sameName := f.Name == columnName(c, i)
699699
sameType := f.Type == trimmedPyType
700700
sameTable := sdk.SameTableName(c.Table, &s.Table, req.Catalog.DefaultSchema)

internal/postgresql_type.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ func postgresType(req *plugin.GenerateRequest, col *plugin.Column) string {
5252
for _, enum := range schema.Enums {
5353
if columnType == enum.Name {
5454
if schema.Name == req.Catalog.DefaultSchema {
55-
return "models." + modelName(enum.Name, req.Settings)
55+
return "db_models." + modelName(enum.Name, req.Settings)
5656
}
57-
return "models." + modelName(schema.Name+"_"+enum.Name, req.Settings)
57+
return "db_models." + modelName(schema.Name+"_"+enum.Name, req.Settings)
5858
}
5959
}
6060
}

0 commit comments

Comments
 (0)
0