aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-01-10 19:03:23 +0800
committerGitHub <noreply@github.com>2024-01-10 11:03:23 +0000
commit2df7563f3176aa8c7dcb070f660d53da4bb66e78 (patch)
treeacf64c3f4d40f15e0fc28d4f6060644172cc46f0 /modules/setting
parenta80debc208fbf0ecf6ca734e454cae08adafb570 (diff)
downloadgitea-2df7563f3176aa8c7dcb070f660d53da4bb66e78.tar.gz
gitea-2df7563f3176aa8c7dcb070f660d53da4bb66e78.zip
Recommend/convert to use case-sensitive collation for MySQL/MSSQL (#28662)
Mainly for MySQL/MSSQL. It is important for Gitea to use case-sensitive database charset collation. If the database is using a case-insensitive collation, Gitea will show startup error/warning messages, and show the errors/warnings on the admin panel's Self-Check page. Make `gitea doctor convert` work for MySQL to convert the collations of database & tables & columns. * Fix #28131 ## :warning: BREAKING :warning: It is not quite breaking, but it's highly recommended to convert the database&table&column to a consistent and case-sensitive collation.
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/database.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/setting/database.go b/modules/setting/database.go
index 015c918d93..0b0488ce85 100644
--- a/modules/setting/database.go
+++ b/modules/setting/database.go
@@ -35,6 +35,7 @@ var (
Path string
LogSQL bool
MysqlCharset string
+ CharsetCollation string
Timeout int // seconds
SQLiteJournalMode string
DBConnectRetries int
@@ -67,7 +68,7 @@ func loadDBSetting(rootCfg ConfigProvider) {
}
Database.Schema = sec.Key("SCHEMA").String()
Database.SSLMode = sec.Key("SSL_MODE").MustString("disable")
- Database.MysqlCharset = sec.Key("MYSQL_CHARSET").MustString("utf8mb4") // do not document it, end users won't need it.
+ Database.CharsetCollation = sec.Key("CHARSET_COLLATION").String()
Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "gitea.db"))
Database.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500)
@@ -105,8 +106,8 @@ func DBConnStr() (string, error) {
if tls == "disable" { // allow (Postgres-inspired) default value to work in MySQL
tls = "false"
}
- connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=%s&parseTime=true&tls=%s",
- Database.User, Database.Passwd, connType, Database.Host, Database.Name, paramSep, Database.MysqlCharset, tls)
+ connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%sparseTime=true&tls=%s",
+ Database.User, Database.Passwd, connType, Database.Host, Database.Name, paramSep, tls)
case "postgres":
connStr = getPostgreSQLConnectionString(Database.Host, Database.User, Database.Passwd, Database.Name, Database.SSLMode)
case "mssql":