Skip to content

Commit

Permalink
Display time in configured time zone in DSN, close github.com/go-gorm…
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jan 2, 2023
1 parent aecc70d commit 332829e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ type localTimeInterface interface {
}

func (dialector Dialector) Explain(sql string, vars ...interface{}) string {
if dialector.DSNConfig != nil && dialector.DSNConfig.Loc == time.Local {
if dialector.DSNConfig != nil && dialector.DSNConfig.Loc != nil {
for i, v := range vars {
if p, ok := v.(localTimeInterface); ok {
func(i int, t localTimeInterface) {
defer func() {
recover()
}()
vars[i] = t.In(time.Local)
vars[i] = t.In(dialector.DSNConfig.Loc)
}(i, p)
}
}
Expand Down

0 comments on commit 332829e

Please sign in to comment.