Skip to content

Commit

Permalink
Merge pull request #29 from tahoe-lafs/zxjon22-cherries
Browse files Browse the repository at this point in the history
Add default MySQL charset if not provided in the configuration file
  • Loading branch information
btlogy authored Oct 29, 2024
2 parents 62711fb + 2ea1013 commit 0ff1012
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions accessor/gitea/defaultAccessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,11 @@ func (accessor *DefaultAccessor) getDbDialect() (gorm.Dialector, string, error)
dialect = sqlite.Open(giteaDbPath)

case "mysql":
connstr := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
url.PathEscape(dbUser), url.PathEscape(dbPassword), dbHost, dbName)
if dbCharset == "utf8" || dbCharset == "" {
dbCharset = "utf8mb4"
}
connstr := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=%s&parseTime=True&loc=Local",
url.PathEscape(dbUser), url.PathEscape(dbPassword), dbHost, dbName, dbCharset)
dialect = mysql.Open(connstr)

case "postgres":
Expand Down

0 comments on commit 0ff1012

Please sign in to comment.