Fix timezone in MySQL connection string (#1818)

Fixes #1643
This commit is contained in:
Zachary Wasserman 2018-06-11 07:31:39 -07:00 committed by GitHub
parent 4ddb691524
commit f8796bc55b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import (
"database/sql"
"fmt"
"io/ioutil"
"net/url"
"time"
"github.com/WatchBeam/clock"
@ -271,12 +272,14 @@ func registerTLS(config config.MysqlConfig) error {
// generateMysqlConnectionString returns a MySQL connection string using the
// provided configuration.
func generateMysqlConnectionString(conf config.MysqlConfig) string {
tz := url.QueryEscape("'-00:00'")
dsn := fmt.Sprintf(
"%s:%s@(%s)/%s?charset=utf8mb4&parseTime=true&loc=UTC&clientFoundRows=true&allowNativePasswords=true",
"%s:%s@(%s)/%s?charset=utf8mb4&parseTime=true&loc=UTC&time_zone=%s&clientFoundRows=true&allowNativePasswords=true",
conf.Username,
conf.Password,
conf.Address,
conf.Database,
tz,
)
if conf.TLSConfig != "" {