# HG changeset patch # User Florent Aide <florent.aide@gmail.com> # Date 1622207795 -7200 # Fri May 28 15:16:35 2021 +0200 # Node ID 6634e1f0eaacd1a2e8682e30603a433583c6b27b # Parent 547b573df49e906a16805dd94468ea5db5084c84 add a FQColumns method on the generate db schemas diff --git a/scripts/generate_db_helpers.go b/scripts/generate_db_helpers.go --- a/scripts/generate_db_helpers.go +++ b/scripts/generate_db_helpers.go @@ -96,6 +96,9 @@ for _, p := range packages { pkg = p } + if pkg == nil { + log.Fatal("pkg cannot be nil here...") + } topLevel := Package{Name: pkg.Name, AllStructs: make(map[string]*ast.StructType)} @@ -506,6 +509,22 @@ return {{.Name}}DataColumns } +// FQColumns returns the database table column names prefixed with the table alias +func (t {{.Name}}TableSchema) FQColumns(withPKey bool) []string { + var colList []string + colList = {{.Name}}DataColumns + + if withPKey { + colList = {{.Name}}Columns + } + + var cols []string + for _, col := range colList { + cols = append(cols, t.GetName()+"."+col) + } + return cols +} + func (t {{.Name}}TableSchema) As(name string) *{{.Name}}TableSchema { t.alias = name {{- range .Fields}}