dialect/entsql: supports setting SQL column comments (#3191)

* feat: Add column comment in SQL DDL, using EntSQL annotations to achieve it.

* Update annotation.go

* fix lint

* Add table primary key column comment

* entsql.Comment(string)  is unnecessary

* entc/gen: minor changes to entsql.WithComments + add tests

Co-authored-by: chenghonour <wantto@outlook.com>
This commit is contained in:
Ariel Mashraki
2022-12-26 14:48:37 +02:00
committed by GitHub
parent 038cc0cace
commit 136807549d
10 changed files with 94 additions and 21 deletions

View File

@@ -912,6 +912,9 @@ func (a *Atlas) aColumns(et *Table, at *schema.Table) error {
if c1.Collation != "" {
c2.SetCollation(c1.Collation)
}
if c1.Comment != "" {
c2.SetComment(c1.Comment)
}
if err := a.sqlDialect.atTypeC(c1, c2); err != nil {
return err
}

View File

@@ -295,6 +295,7 @@ type Column struct {
typ string // row column type (used for Rows.Scan).
indexes Indexes // linked indexes.
foreign *ForeignKey // linked foreign-key.
Comment string // column comment.
}
// Expr represents a raw expression. It is used to distinguish between