mirror of
https://github.com/ent/ent.git
synced 2026-05-05 00:50:54 +03:00
dialect/sql/schema: add field collation support (#1548)
* specific field collation support * go generate ./...
This commit is contained in:
@@ -176,6 +176,7 @@ type Column struct {
|
||||
Nullable bool // null or not null attribute.
|
||||
Default interface{} // default value.
|
||||
Enums []string // enum values.
|
||||
Collation string // collation type (utf8mb4_unicode_ci, utf8mb4_general_ci)
|
||||
typ string // row column type (used for Rows.Scan).
|
||||
indexes Indexes // linked indexes.
|
||||
foreign *ForeignKey // linked foreign-key.
|
||||
@@ -307,6 +308,13 @@ func (c Column) supportDefault() bool {
|
||||
}
|
||||
}
|
||||
|
||||
// collation adds `COLLATE collation_name`.
|
||||
func (c *Column) collation(b *sql.ColumnBuilder) {
|
||||
if c.Collation != "" {
|
||||
b.Attr("COLLATE " + c.Collation)
|
||||
}
|
||||
}
|
||||
|
||||
// unique adds the `UNIQUE` attribute if the column is a unique type.
|
||||
// it is exist in a different function to share the common declaration
|
||||
// between the two dialects.
|
||||
|
||||
Reference in New Issue
Block a user