From e09c69d374496fa6e0fbd4b6ee2585226677349c Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 6 Jun 2018 14:23:01 -0400 Subject: [PATCH] Use available column types for cockroachdb/postgres --- dialect_postgres.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dialect_postgres.go b/dialect_postgres.go index d3d37918..c2fa3f96 100644 --- a/dialect_postgres.go +++ b/dialect_postgres.go @@ -1020,7 +1020,7 @@ WHERE c.relkind = 'r'::char AND c.relname = $1%s AND f.attnum > 0 ORDER BY f.att col.Nullable = (isNullable == "YES") switch strings.ToLower(dataType) { - case "character varying", "character", "string": + case "character varying", "character": col.SQLType = core.SQLType{Name: core.Varchar, DefaultLength: 0, DefaultLength2: 0} case "timestamp without time zone": col.SQLType = core.SQLType{Name: core.DateTime, DefaultLength: 0, DefaultLength2: 0} @@ -1037,11 +1037,11 @@ WHERE c.relkind = 'r'::char AND c.relname = $1%s AND f.attnum > 0 ORDER BY f.att case "oid": col.SQLType = core.SQLType{Name: core.BigInt, DefaultLength: 0, DefaultLength2: 0} default: - startIdx := strings.Index(strings.ToLower(dataType), "string(") + startIdx := strings.Index(strings.ToLower(dataType), "varchar(") if startIdx != -1 && strings.HasSuffix(dataType, ")") { length := dataType[startIdx+8 : len(dataType)-1] l, _ := strconv.Atoi(length) - col.SQLType = core.SQLType{Name: "STRING", DefaultLength: l, DefaultLength2: 0} + col.SQLType = core.SQLType{Name: "varchar", DefaultLength: l, DefaultLength2: 0} } else { col.SQLType = core.SQLType{Name: strings.ToUpper(dataType), DefaultLength: 0, DefaultLength2: 0} }