From cdec8d5e8e21082536099fb557ab87b22c4c1587 Mon Sep 17 00:00:00 2001 From: Jerry <85411418@qq.com> Date: Tue, 10 Mar 2020 13:47:22 +0800 Subject: [PATCH] =?UTF-8?q?fix=20err=EF=BC=8Cadd=20postgres=20column=20ARR?= =?UTF-8?q?AY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dialects/postgres.go | 2 ++ schemas/type.go | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/dialects/postgres.go b/dialects/postgres.go index 8412ad40..2111f195 100644 --- a/dialects/postgres.go +++ b/dialects/postgres.go @@ -1099,6 +1099,8 @@ WHERE c.relkind = 'r'::char AND c.relname = $1%s AND f.attnum > 0 ORDER BY f.att col.SQLType = schemas.SQLType{Name: schemas.Binary, DefaultLength: 0, DefaultLength2: 0} case "oid": col.SQLType = schemas.SQLType{Name: schemas.BigInt, DefaultLength: 0, DefaultLength2: 0} + case "array": + col.SQLType = schemas.SQLType{Name: schemas.Array, DefaultLength: 0, DefaultLength2: 0} default: startIdx := strings.Index(strings.ToLower(dataType), "string(") if startIdx != -1 && strings.HasSuffix(dataType, ")") { diff --git a/schemas/type.go b/schemas/type.go index 39f1bf4e..e8ccdf39 100644 --- a/schemas/type.go +++ b/schemas/type.go @@ -34,6 +34,7 @@ const ( BLOB_TYPE TIME_TYPE NUMERIC_TYPE + ARRAY_TYPE ) func (s *SQLType) IsType(st int) bool { @@ -59,6 +60,10 @@ func (s *SQLType) IsNumeric() bool { return s.IsType(NUMERIC_TYPE) } +func (s *SQLType) IsArray() bool { + return s.IsType(ARRAY_TYPE) +} + func (s *SQLType) IsJson() bool { return s.Name == Json || s.Name == Jsonb } @@ -123,6 +128,8 @@ var ( Json = "JSON" Jsonb = "JSONB" + Array = "ARRAY" + SqlTypes = map[string]int{ Bit: NUMERIC_TYPE, TinyInt: NUMERIC_TYPE, @@ -149,6 +156,7 @@ var ( Uuid: TEXT_TYPE, Clob: TEXT_TYPE, SysName: TEXT_TYPE, + Array: TEXT_TYPE, Date: TIME_TYPE, DateTime: TIME_TYPE, @@ -180,6 +188,8 @@ var ( Serial: NUMERIC_TYPE, BigSerial: NUMERIC_TYPE, + + Array: ARRAY_TYPE, } intTypes = sort.StringSlice{"*int", "*int16", "*int32", "*int8"}