dialect/sql/schema: initial support for postgres net-types (#964)

This commit is contained in:
Ariel Mashraki
2020-11-20 15:30:54 +02:00
committed by GitHub
parent f655a59089
commit 3d2feec5e2
4 changed files with 17 additions and 3 deletions

View File

@@ -249,6 +249,8 @@ func (d *Postgres) scanColumn(c *Column, rows *sql.Rows) error {
c.Type = field.TypeJSON
case "uuid":
c.Type = field.TypeUUID
case "cidr", "inet", "macaddr", "macaddr8":
c.Type = field.TypeOther
}
switch {
case !defaults.Valid || c.Type == field.TypeTime || seqfunc(defaults.String):
@@ -310,6 +312,8 @@ func (d *Postgres) cType(c *Column) (t string) {
// Currently, the support for enums is weak (application level only.
// like SQLite). Dialect needs to create and maintain its enum type.
t = "varchar"
case field.TypeOther:
t = c.typ
default:
panic(fmt.Sprintf("unsupported type %q for column %q", c.Type.String(), c.Name))
}