Skip to content

Commit

Permalink
add new mysql option to with supporting of nano second
Browse files Browse the repository at this point in the history
  • Loading branch information
XIELongDragon committed May 30, 2022
1 parent c25530b commit c1a00dc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dialect/mysql/mysql.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package mysql

import (
"time"

"github.com/doug-martin/goqu/v9"
"github.com/doug-martin/goqu/v9/exp"
)
Expand Down Expand Up @@ -86,11 +84,17 @@ func DialectOptions() *goqu.SQLDialectOptions {
func DialectOptionsV8() *goqu.SQLDialectOptions {
opts := DialectOptions()
opts.SupportsWindowFunction = true
opts.TimeFormat = time.RFC3339Nano
return opts
}

func DialectOptionsV8Nano() *goqu.SQLDialectOptions {
opts := DialectOptionsV8()
opts.TimeFormat = "2006-01-02 15:04:05.999999999"
return opts
}

func init() {
goqu.RegisterDialect("mysql", "db", DialectOptions())
goqu.RegisterDialect("mysql8", "db", DialectOptionsV8())
goqu.RegisterDialect("mysql8nano", "db", DialectOptionsV8Nano())
}

0 comments on commit c1a00dc

Please sign in to comment.