dialect/sql/schemma: ignore pgtime default value on scanning (#468)

This commit is contained in:
Ariel Mashraki
2020-05-06 22:34:01 +03:00
committed by GitHub
parent 196a764691
commit f384701c04
3 changed files with 3 additions and 3 deletions

View File

@@ -230,7 +230,7 @@ func (d *Postgres) scanColumn(c *Column, rows *sql.Rows) error {
c.Type = field.TypeUUID
}
switch {
case !defaults.Valid:
case !defaults.Valid || c.Type == field.TypeTime:
return nil
case strings.Contains(defaults.String, "::"):
parts := strings.Split(defaults.String, "::")

View File

@@ -152,7 +152,7 @@ func TestPostgres_Create(t *testing.T) {
AddRow("id", "bigint", "NO", "NULL").
AddRow("name", "character varying", "YES", "NULL").
AddRow("uuid", "uuid", "YES", "NULL").
AddRow("date", "date", "NO", "NULL").
AddRow("date", "date", "NO", "CURRENT_DATE").
AddRow("text", "text", "YES", "NULL"))
mock.ExpectQuery(escape(fmt.Sprintf(indexesQuery, "users"))).
WillReturnRows(sqlmock.NewRows([]string{"index_name", "column_name", "primary", "unique", "seq_in_index"}).

View File

@@ -185,7 +185,7 @@ func (c Column) UintType() bool { return c.Type >= field.TypeUint8 && c.Type <=
func (c Column) FloatType() bool { return c.Type == field.TypeFloat32 || c.Type == field.TypeFloat64 }
// ScanDefault scans the default value string to its interface type.
func (c *Column) ScanDefault(value string) (err error) {
func (c *Column) ScanDefault(value string) error {
switch {
case strings.ToUpper(value) == Null: // ignore.
case c.IntType():