dialect/sql/schema: alter table for postgres

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/115

Reviewed By: alexsn

Differential Revision: D18065988

fbshipit-source-id: a7d33bbebd63b01659bc5ba562ac85642dcd3d83
This commit is contained in:
Ariel Mashraki
2019-10-22 12:54:04 -07:00
committed by Facebook Github Bot
parent dff3067639
commit 2789257849
4 changed files with 47 additions and 9 deletions

View File

@@ -397,7 +397,7 @@ func (c *Column) ScanMySQL(rows *sql.Rows) error {
c.Enums[i] = strings.Trim(e, "'")
}
}
if defaults.Valid && defaults.String != Null {
if defaults.Valid {
return c.ScanDefault(defaults.String)
}
return nil
@@ -429,6 +429,7 @@ func (c Column) FloatType() bool { return c.Type == field.TypeFloat32 || c.Type
// ScanDefault scans the default value string to its interface type.
func (c *Column) ScanDefault(value string) (err error) {
switch {
case value == Null: // ignore.
case c.IntType():
v := &sql.NullInt64{}
if err := v.Scan(value); err != nil {