diff --git a/database/drivers/postgres/parse.go b/database/drivers/postgres/parse.go index 25fec4f..aca1fc2 100644 --- a/database/drivers/postgres/parse.go +++ b/database/drivers/postgres/parse.go @@ -482,7 +482,9 @@ func queryIndexes(log *log.Logger, db *sql.DB, schemaNames []string) ([]indexRes // postgres prepends schema onto table name if outside of public schema if r.SchemaName != "public" { - r.TableName = r.TableName[len(r.SchemaName)+1:] + if strings.Contains(r.TableName, r.SchemaName) { + r.TableName = r.TableName[len(r.SchemaName)+1:] + } } results = append(results, r) @@ -535,7 +537,8 @@ func queryColumnComments(log *log.Logger, db *sql.DB, schemaNames []string) ([]c } if c.Valid { - r.Comment = c.String + replaced := strings.Replace(c.String, "\n", " ", -1) + r.Comment = replaced results = append(results, r) } } @@ -585,7 +588,8 @@ func queryTableComments(log *log.Logger, db *sql.DB, schemaNames []string) ([]ta } if c.Valid { - r.Comment = c.String + replaced := strings.Replace(c.String, "\n", " ", -1) + r.Comment = replaced results = append(results, r) } } diff --git a/environ/funcs.go b/environ/funcs.go index 1cc748e..f4f5b14 100644 --- a/environ/funcs.go +++ b/environ/funcs.go @@ -38,6 +38,7 @@ var FuncMap = map[string]interface{}{ "makeMap": makeMap, "makeSlice": makeSlice, "numbers": numbers, + "steps": steps, "pascal": kace.Pascal, "repeat": strings.Repeat, "replace": strings.Replace, @@ -138,6 +139,15 @@ func numbers(start, end int) data.Strings { return s } +// steps returns a slice of strings of the numbers from start with length of len +func steps(start, len int) data.Strings { + var s data.Strings + for x := 0; x < len; x++ { + s = append(s, strconv.Itoa(start+x)) + } + return s +} + // Plugin returns a function which can be used in templates for executing plugins, // dirs is the list of directories which are used fo plugin lookup. func Plugin(dirs []string) func(string, string, interface{}) (interface{}, error) {