PostgreSQL accepts microsecond for timestamp

This commit is contained in:
MURAOKA Taro 2020-04-15 12:01:13 +09:00
parent 34dc7f8791
commit a18e06ff25
1 changed files with 7 additions and 1 deletions

View File

@ -18,8 +18,14 @@ func FormatTime(dialect Dialect, sqlTypeName string, t time.Time) (v interface{}
v = s[11:19]
case schemas.Date:
v = t.Format("2006-01-02")
case schemas.DateTime, schemas.TimeStamp, schemas.Varchar: // !DarthPestilane! format time when sqlTypeName is schemas.Varchar.
case schemas.DateTime, schemas.Varchar: // !DarthPestilane! format time when sqlTypeName is schemas.Varchar.
v = t.Format("2006-01-02 15:04:05")
case schemas.TimeStamp:
if dialect.URI().DBType == schemas.POSTGRES {
v = t.Format("2006-01-02T15:04:05.999999")
} 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")