Skip to content

Commit

Permalink
fix psql comments
Browse files Browse the repository at this point in the history
  • Loading branch information
n-r-w authored and kenshaw committed Jan 12, 2024
1 parent a4a58e2 commit ce2cf40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gen.sh
Expand Up @@ -157,7 +157,7 @@ SELECT
c.relname::varchar AS table_name,
false::boolean AS manual_pk,
CASE c.relkind
WHEN 'r' THEN ''
WHEN 'r' THEN COALESCE(obj_description(c.relname::regclass), '')
WHEN 'v' THEN v.definition
END AS view_def
FROM pg_class c
Expand Down
2 changes: 1 addition & 1 deletion models/table.xo.go

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

9 changes: 8 additions & 1 deletion templates/go/go.go
Expand Up @@ -661,6 +661,7 @@ func convertTable(ctx context.Context, t xo.Table) (Table, error) {
Fields: cols,
PrimaryKeys: pkCols,
Manual: t.Manual,
Comment: t.Definition,
}, nil
}

Expand Down Expand Up @@ -1916,7 +1917,13 @@ func (f *Funcs) field(field Field) (string, error) {
if s := buf.String(); s != "" {
tag = " `" + s + "`"
}
return fmt.Sprintf("\t%s %s%s // %s", field.GoName, f.typefn(field.Type), tag, field.SQLName), nil

comment := field.SQLName
if field.Comment != "" {
comment = field.Comment
}

return fmt.Sprintf("\t%s %s%s // %s", field.GoName, f.typefn(field.Type), tag, comment), nil
}

// short generates a safe Go identifier for typ. typ is first checked
Expand Down

0 comments on commit ce2cf40

Please sign in to comment.