Skip to content

Commit

Permalink
fix: Honor Package level renames in v2 yaml config (#2001)
Browse files Browse the repository at this point in the history
Package level config renames override global level config renames
  • Loading branch information
Emyrk committed Apr 7, 2023
1 parent b4d2e91 commit da6aee2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/config/config.go
Expand Up @@ -213,13 +213,19 @@ func Combine(conf Config, pkg SQL) CombinedSettings {
cs := CombinedSettings{
Global: conf,
Package: pkg,
Rename: map[string]string{},
}
if conf.Gen.Go != nil {
cs.Rename = conf.Gen.Go.Rename
for k, v := range conf.Gen.Go.Rename {
cs.Rename[k] = v
}
cs.Overrides = append(cs.Overrides, conf.Gen.Go.Overrides...)
}
if pkg.Gen.Go != nil {
cs.Go = *pkg.Gen.Go
for k, v := range pkg.Gen.Go.Rename {
cs.Rename[k] = v
}
cs.Overrides = append(cs.Overrides, pkg.Gen.Go.Overrides...)
}
if pkg.Gen.JSON != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/config/v_two.go
Expand Up @@ -89,6 +89,9 @@ func v2ParseConfig(rd io.Reader) (Config, error) {
return conf, err
}
}
for k, v := range conf.SQL[j].Gen.Go.Rename {
conf.SQL[j].Gen.Go.Rename[k] = v
}
}
if conf.SQL[j].Gen.JSON != nil {
if conf.SQL[j].Gen.JSON.Out == "" {
Expand Down

0 comments on commit da6aee2

Please sign in to comment.