summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-05-24 12:15:26 +0800
committertechknowlogick <techknowlogick@gitea.io>2019-05-24 00:15:26 -0400
commitd5a98a29690e13f717fb72e8635fbea57e58f546 (patch)
treeb956c947814221d7a03bebc8516323266e81660e /models
parent181b7c99eddb373b4415b160dde9109cd4191878 (diff)
downloadgitea-d5a98a29690e13f717fb72e8635fbea57e58f546.tar.gz
gitea-d5a98a29690e13f717fb72e8635fbea57e58f546.zip
Add support of utf8mb4 for mysql (#6992)
Diffstat (limited to 'models')
-rw-r--r--models/models.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/models/models.go b/models/models.go
index c7e58737ed..85318af870 100644
--- a/models/models.go
+++ b/models/models.go
@@ -59,8 +59,8 @@ var (
// DbCfg holds the database settings
DbCfg struct {
- Type, Host, Name, User, Passwd, Path, SSLMode string
- Timeout int
+ Type, Host, Name, User, Passwd, Path, SSLMode, Charset string
+ Timeout int
}
// EnableSQLite3 use SQLite3
@@ -160,6 +160,7 @@ func LoadConfigs() {
DbCfg.Passwd = sec.Key("PASSWD").String()
}
DbCfg.SSLMode = sec.Key("SSL_MODE").MustString("disable")
+ DbCfg.Charset = sec.Key("CHARSET").In("utf8", []string{"utf8", "utf8mb4"})
DbCfg.Path = sec.Key("PATH").MustString(filepath.Join(setting.AppDataPath, "gitea.db"))
DbCfg.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500)
}
@@ -222,8 +223,8 @@ func getEngine() (*xorm.Engine, error) {
if tls == "disable" { // allow (Postgres-inspired) default value to work in MySQL
tls = "false"
}
- connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=utf8&parseTime=true&tls=%s",
- DbCfg.User, DbCfg.Passwd, connType, DbCfg.Host, DbCfg.Name, Param, tls)
+ connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=%s&parseTime=true&tls=%s",
+ DbCfg.User, DbCfg.Passwd, connType, DbCfg.Host, DbCfg.Name, Param, DbCfg.Charset, tls)
case "postgres":
connStr = getPostgreSQLConnectionString(DbCfg.Host, DbCfg.User, DbCfg.Passwd, DbCfg.Name, Param, DbCfg.SSLMode)
case "mssql":