fix(ci): the local time zone is different from the database time causing CI to fail
This commit is contained in:
parent
ed17be6735
commit
096563cbf1
|
@ -233,8 +233,8 @@ func (statement *Statement) writeForUpdate(w *builder.BytesWriter) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if statement.dialect.URI().DBType != schemas.MYSQL {
|
||||
return errors.New("only support mysql for update")
|
||||
if statement.dialect.URI().DBType != schemas.MYSQL && statement.dialect.URI().DBType != schemas.POSTGRES {
|
||||
return errors.New("only support mysql and postgres for update")
|
||||
}
|
||||
_, err := fmt.Fprint(w, " FOR UPDATE")
|
||||
return err
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm/v2"
|
||||
|
||||
|
@ -93,7 +94,6 @@ func createEngine(dbType, connStr string) error {
|
|||
}
|
||||
}
|
||||
db.Close()
|
||||
*ignoreSelectUpdate = true
|
||||
case schemas.MYSQL:
|
||||
db, err := sql.Open(dbType, strings.ReplaceAll(connStr, "xorm_test", "mysql"))
|
||||
if err != nil {
|
||||
|
@ -115,6 +115,19 @@ func createEngine(dbType, connStr string) error {
|
|||
}
|
||||
|
||||
testEngine, err = xorm.NewEngine(dbType, connStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var timeZone string
|
||||
_, err = testEngine.SQL("SHOW TIMEZONE").Get(&timeZone)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if strings.EqualFold(timeZone, "UTC") {
|
||||
testEngine.SetTZDatabase(time.UTC)
|
||||
}
|
||||
} else {
|
||||
testEngine, err = xorm.NewEngineGroup(dbType, strings.Split(connStr, *splitter))
|
||||
if dbType != "mysql" {
|
||||
|
|
Loading…
Reference in New Issue