Skip to content

Commit

Permalink
adjust sql comment ;
Browse files Browse the repository at this point in the history
  • Loading branch information
liujianping committed May 10, 2021
1 parent 5f2bb4a commit e9be724
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
1 change: 1 addition & 0 deletions gen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func generateCode(in string, out string, suffix string, objects ...string) error
log.Println("gofmt: ", err)
}
}

for _, tb := range tables {
outfile := filepath.Join(out, fmt.Sprintf("gen.table.%s.go", tb.Name()))
wr, err := os.OpenFile(outfile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
Expand Down
6 changes: 6 additions & 0 deletions object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ type Object struct {
Attributes map[string]interface{} `yaml:"attributes,omitempty"`
}

func (obj *Object) Adjust() {
obj.Comment = strings.ReplaceAll(obj.Comment, ";", "")
for _, field := range obj.Fields {
field.Comment = strings.ReplaceAll(field.Comment, ";", "")
}
}
func (obj *Object) IsTable() bool {
if strings.ToLower(obj.Object) == "table" {
return true
Expand Down
1 change: 1 addition & 0 deletions parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func Parse(filename string) ([]*object.Object, error) {
if err != nil {
return nil, err
}
obj.Adjust()
objs = append(objs, &obj)
}
return objs, nil
Expand Down
4 changes: 2 additions & 2 deletions tpl/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e9be724

Please sign in to comment.