From 55a8e63aada0a2b91b642f3ccaf635f464e674a8 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Wed, 16 Mar 2016 23:06:15 +0800 Subject: [PATCH] If size haven't been set, use `text` as string's default type for postgres, close #910 --- dialect_postgres.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dialect_postgres.go b/dialect_postgres.go index 18cbe028..09ac5961 100644 --- a/dialect_postgres.go +++ b/dialect_postgres.go @@ -45,6 +45,10 @@ func (postgres) DataTypeOf(field *StructField) string { case reflect.Float32, reflect.Float64: sqlType = "numeric" case reflect.String: + if _, ok := field.TagSettings["SIZE"]; !ok { + size = 0 // if SIZE haven't been set, use `text` as the default type, as there are no performance different + } + if size > 0 && size < 65532 { sqlType = fmt.Sprintf("varchar(%d)", size) } else {