mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql/schema: support mediumtext field in migration
Fixed https://github.com/ent/ent/issues/2113
This commit is contained in:
committed by
Ariel Mashraki
parent
8f88f58713
commit
dd6c034c2a
@@ -250,9 +250,14 @@ func (d *MySQL) cType(c *Column) (t string) {
|
||||
if size == 0 {
|
||||
size = d.defaultSize(c)
|
||||
}
|
||||
if size <= math.MaxUint16 {
|
||||
switch {
|
||||
case c.typ == "tinytext", c.typ == "text":
|
||||
t = c.typ
|
||||
case size <= math.MaxUint16:
|
||||
t = fmt.Sprintf("varchar(%d)", size)
|
||||
} else {
|
||||
case size == 1<<24-1:
|
||||
t = "mediumtext"
|
||||
default:
|
||||
t = "longtext"
|
||||
}
|
||||
case field.TypeFloat32, field.TypeFloat64:
|
||||
|
||||
@@ -250,6 +250,7 @@ func TestMySQL_Create(t *testing.T) {
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString, Nullable: true},
|
||||
{Name: "text", Type: field.TypeString, Nullable: true, Size: math.MaxInt32},
|
||||
{Name: "mediumtext", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{dialect.MySQL: "mediumtext"}},
|
||||
{Name: "uuid", Type: field.TypeUUID, Nullable: true},
|
||||
{Name: "date", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{dialect.MySQL: "date"}},
|
||||
{Name: "age", Type: field.TypeInt},
|
||||
@@ -278,6 +279,7 @@ func TestMySQL_Create(t *testing.T) {
|
||||
AddRow("id", "bigint(20)", "NO", "PRI", "NULL", "auto_increment", "", "", nil, nil).
|
||||
AddRow("name", "varchar(255)", "YES", "YES", "NULL", "", "", "", nil, nil).
|
||||
AddRow("text", "longtext", "YES", "YES", "NULL", "", "", "", nil, nil).
|
||||
AddRow("mediumtext", "mediumtext", "YES", "YES", "NULL", "", "", "", nil, nil).
|
||||
AddRow("uuid", "char(36)", "YES", "YES", "NULL", "", "", "utf8mb4_bin", nil, nil).
|
||||
AddRow("date", "date", "YES", "YES", "NULL", "", "", "", nil, nil).
|
||||
// 8.0.19: new int column type formats
|
||||
|
||||
Reference in New Issue
Block a user