Merge pull request 'fix oracle insert datetime (#1873)' (#1) from xorm/xorm:master into master

Reviewed-on: https://gitea.com/4color/xorm/pulls/1
This commit is contained in:
4color 2021-03-05 13:31:52 +08:00
commit 0b563c8774
1 changed files with 5 additions and 1 deletions

View File

@ -19,7 +19,11 @@ func FormatTime(dialect Dialect, sqlTypeName string, t time.Time) (v interface{}
case schemas.Date:
v = t.Format("2006-01-02")
case schemas.DateTime, schemas.TimeStamp, schemas.Varchar: // !DarthPestilane! format time when sqlTypeName is schemas.Varchar.
v = t.Format("2006-01-02 15:04:05")
if dialect.URI().DBType == schemas.ORACLE {
v = t
} else {
v = t.Format("2006-01-02 15:04:05")
}
case schemas.TimeStampz:
if dialect.URI().DBType == schemas.MSSQL {
v = t.Format("2006-01-02T15:04:05.9999999Z07:00")