|
59 | 59 |
|
60 | 60 | // DbCfg holds the database settings
|
61 | 61 | DbCfg struct {
|
62 |
| - Type, Host, Name, User, Passwd, Path, SSLMode string |
63 |
| - Timeout int |
| 62 | + Type, Host, Name, User, Passwd, Path, SSLMode, Charset string |
| 63 | + Timeout int |
64 | 64 | }
|
65 | 65 |
|
66 | 66 | // EnableSQLite3 use SQLite3
|
@@ -160,6 +160,7 @@ func LoadConfigs() {
|
160 | 160 | DbCfg.Passwd = sec.Key("PASSWD").String()
|
161 | 161 | }
|
162 | 162 | DbCfg.SSLMode = sec.Key("SSL_MODE").MustString("disable")
|
| 163 | + DbCfg.Charset = sec.Key("CHARSET").In("utf8", []string{"utf8", "utf8mb4"}) |
163 | 164 | DbCfg.Path = sec.Key("PATH").MustString(filepath.Join(setting.AppDataPath, "gitea.db"))
|
164 | 165 | DbCfg.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500)
|
165 | 166 | }
|
@@ -222,8 +223,8 @@ func getEngine() (*xorm.Engine, error) {
|
222 | 223 | if tls == "disable" { // allow (Postgres-inspired) default value to work in MySQL
|
223 | 224 | tls = "false"
|
224 | 225 | }
|
225 |
| - connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=utf8&parseTime=true&tls=%s", |
226 |
| - DbCfg.User, DbCfg.Passwd, connType, DbCfg.Host, DbCfg.Name, Param, tls) |
| 226 | + connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=%s&parseTime=true&tls=%s", |
| 227 | + DbCfg.User, DbCfg.Passwd, connType, DbCfg.Host, DbCfg.Name, Param, DbCfg.Charset, tls) |
227 | 228 | case "postgres":
|
228 | 229 | connStr = getPostgreSQLConnectionString(DbCfg.Host, DbCfg.User, DbCfg.Passwd, DbCfg.Name, Param, DbCfg.SSLMode)
|
229 | 230 | case "mssql":
|
|
0 commit comments