Implemented postgres table and enum comment generation
This commit is contained in:
parent
929109622e
commit
ff82eb5df7
4 changed files with 33 additions and 3 deletions
|
|
@ -1,8 +1,11 @@
|
|||
package metadata
|
||||
|
||||
import "regexp"
|
||||
|
||||
// Table metadata struct
|
||||
type Table struct {
|
||||
Name string `sql:"primary_key"`
|
||||
Comment string
|
||||
Columns []Column
|
||||
}
|
||||
|
||||
|
|
@ -20,3 +23,13 @@ func (t Table) MutableColumns() []Column {
|
|||
|
||||
return ret
|
||||
}
|
||||
|
||||
// GoLangComment returns table comment without ascii control characters
|
||||
func (t Table) GoLangComment() string {
|
||||
if t.Comment == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
// remove ascii control characters from string
|
||||
return regexp.MustCompile(`[[:cntrl:]]+`).ReplaceAllString(t.Comment, "")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue