Implemented postgres table and enum comment generation

This commit is contained in:
Volker Lieber 2024-09-24 20:41:27 +02:00
parent 929109622e
commit ff82eb5df7
4 changed files with 33 additions and 3 deletions

View file

@ -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, "")
}