From 67d67289c7e2aa5ed2a461275fa8c4bfcc847002 Mon Sep 17 00:00:00 2001 From: m2nlight Date: Tue, 21 Nov 2017 13:25:36 +0800 Subject: [PATCH] models: add utf8mb4 to connStr for mysql (#4878) --- models/models.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/models.go b/models/models.go index f26dd07ac..5cc5c9c22 100644 --- a/models/models.go +++ b/models/models.go @@ -134,10 +134,10 @@ func getEngine() (*xorm.Engine, error) { switch DbCfg.Type { case "mysql": if DbCfg.Host[0] == '/' { // looks like a unix socket - connStr = fmt.Sprintf("%s:%s@unix(%s)/%s%scharset=utf8&parseTime=true", + connStr = fmt.Sprintf("%s:%s@unix(%s)/%s%scharset=utf8mb4,utf8&parseTime=true", DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param) } else { - connStr = fmt.Sprintf("%s:%s@tcp(%s)/%s%scharset=utf8&parseTime=true", + connStr = fmt.Sprintf("%s:%s@tcp(%s)/%s%scharset=utf8mb4,utf8&parseTime=true", DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param) } case "postgres":