dialect/sql/schema: apply size-check only if it is defined in schema (#855)

This commit is contained in:
Ariel Mashraki
2020-10-15 14:17:32 +03:00
committed by GitHub
parent 119cdf207e
commit 2128d0baee
18 changed files with 653 additions and 6 deletions

View File

@@ -165,7 +165,11 @@ func (c *Column) PrimaryKey() bool { return c.Key == PrimaryKey }
func (c *Column) ConvertibleTo(d *Column) bool {
switch {
case c.Type == d.Type:
return c.Size <= d.Size
if c.Size != 0 && d.Size != 0 {
// Types match and have a size constraint.
return c.Size <= d.Size
}
return true
case c.IntType() && d.IntType() || c.UintType() && d.UintType():
return c.Type <= d.Type
case c.UintType() && d.IntType():