diff options
author | =Corey Hulen <corey@hulen.com> | 2015-07-15 10:22:05 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-07-15 10:22:05 -0800 |
commit | e017babc5ddd66e65469326bf723d5359875c2d1 (patch) | |
tree | 0da7ee5d9f4039eeb20f70940483c40943c9aa23 /store/sql_store.go | |
parent | 252d0f3924dd19aa4dd1900c6c00c41c84755d1e (diff) | |
parent | 38f9e140e98123eb256968fb31f7fbb2aef978e0 (diff) | |
download | chat-e017babc5ddd66e65469326bf723d5359875c2d1.tar.gz chat-e017babc5ddd66e65469326bf723d5359875c2d1.tar.bz2 chat-e017babc5ddd66e65469326bf723d5359875c2d1.zip |
fixing merge
Diffstat (limited to 'store/sql_store.go')
-rw-r--r-- | store/sql_store.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/store/sql_store.go b/store/sql_store.go index a0a1a9f23..7a2d059b9 100644 --- a/store/sql_store.go +++ b/store/sql_store.go @@ -24,6 +24,7 @@ import ( sqltrace "log" "math/rand" "os" + "strings" "time" ) @@ -81,7 +82,14 @@ func NewSqlStore() Store { func setupConnection(con_type string, driver string, dataSource string, maxIdle int, maxOpen int, trace bool) *gorp.DbMap { - db, err := dbsql.Open(driver, dataSource) + charset := "" + if strings.Index(dataSource, "?") > -1 { + charset = "&charset=utf8mb4,utf8" + } else { + charset = "?charset=utf8mb4,utf8" + } + + db, err := dbsql.Open(driver, dataSource+charset) if err != nil { l4g.Critical("Failed to open sql connection to '%v' err:%v", dataSource, err) time.Sleep(time.Second) @@ -104,7 +112,7 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle if driver == "sqlite3" { dbmap = &gorp.DbMap{Db: db, TypeConverter: mattermConverter{}, Dialect: gorp.SqliteDialect{}} } else if driver == "mysql" { - dbmap = &gorp.DbMap{Db: db, TypeConverter: mattermConverter{}, Dialect: gorp.MySQLDialect{Engine: "InnoDB", Encoding: "UTF8"}} + dbmap = &gorp.DbMap{Db: db, TypeConverter: mattermConverter{}, Dialect: gorp.MySQLDialect{Engine: "InnoDB", Encoding: "UTF8MB4"}} } else { l4g.Critical("Failed to create dialect specific driver") time.Sleep(time.Second) |