From 51858169424ab750be8bcf924645bd7679926419 Mon Sep 17 00:00:00 2001 From: miraclesu Date: Tue, 12 Apr 2016 21:19:43 +0800 Subject: [PATCH] orm: use `text` as postgres default type --- orm/cmd_utils.go | 6 +++++- orm/models_info_f.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/orm/cmd_utils.go b/orm/cmd_utils.go index 94e6070b..8119b70b 100644 --- a/orm/cmd_utils.go +++ b/orm/cmd_utils.go @@ -52,7 +52,11 @@ checkColumn: case TypeBooleanField: col = T["bool"] case TypeCharField: - col = fmt.Sprintf(T["string"], fieldSize) + if al.Driver == DRPostgres && fi.toText { + col = T["string-text"] + } else { + col = fmt.Sprintf(T["string"], fieldSize) + } case TypeTextField: col = T["string-text"] case TypeTimeField: diff --git a/orm/models_info_f.go b/orm/models_info_f.go index 366473ce..be6c9aa4 100644 --- a/orm/models_info_f.go +++ b/orm/models_info_f.go @@ -119,6 +119,7 @@ type fieldInfo struct { colDefault bool initial StrTo size int + toText bool autoNow bool autoNowAdd bool rel bool @@ -359,6 +360,7 @@ checkType: } } else { fi.size = 255 + fi.toText = true } case TypeTextField: fi.index = false