summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom <tom@carrio.me>2016-07-02 10:39:39 -0400
committer无闻 <u@gogs.io>2016-07-02 22:39:39 +0800
commit528682a294834611a95b2cf6c80efdccdf6fd791 (patch)
tree536c7a81ed4594ef64841e888fafabdfb0c6d44a
parent6aa00f7bcf707a103df1b5ef5976da01a3838a13 (diff)
downloadgitea-528682a294834611a95b2cf6c80efdccdf6fd791.tar.gz
gitea-528682a294834611a95b2cf6c80efdccdf6fd791.zip
getEngine() not handles DB parameters (#2972) (#2974)
-rw-r--r--models/models.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/models/models.go b/models/models.go
index b705bdad41..90fa3f6465 100644
--- a/models/models.go
+++ b/models/models.go
@@ -97,14 +97,18 @@ func LoadConfigs() {
func getEngine() (*xorm.Engine, error) {
cnnstr := ""
+ var Param string = "?"
+ if strings.Contains(DbCfg.Name,Param) {
+ Param="&"
+ }
switch DbCfg.Type {
case "mysql":
if DbCfg.Host[0] == '/' { // looks like a unix socket
- cnnstr = fmt.Sprintf("%s:%s@unix(%s)/%s?charset=utf8&parseTime=true",
- DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
+ cnnstr = fmt.Sprintf("%s:%s@unix(%s)/%s%scharset=utf8&parseTime=true",
+ DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param)
} else {
- cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=true",
- DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
+ cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s%scharset=utf8&parseTime=true",
+ DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param)
}
case "postgres":
var host, port = "127.0.0.1", "5432"
@@ -115,8 +119,8 @@ func getEngine() (*xorm.Engine, error) {
if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 {
port = fields[1]
}
- cnnstr = fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=%s",
- url.QueryEscape(DbCfg.User), url.QueryEscape(DbCfg.Passwd), host, port, DbCfg.Name, DbCfg.SSLMode)
+ cnnstr = fmt.Sprintf("postgres://%s:%s@%s:%s/%s%ssslmode=%s",
+ url.QueryEscape(DbCfg.User), url.QueryEscape(DbCfg.Passwd), host, port, DbCfg.Name, Param, DbCfg.SSLMode)
case "sqlite3":
if !EnableSQLite3 {
return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type)