diff --git a/dialects/time.go b/dialects/time.go index 5aee0c10..64f6206d 100644 --- a/dialects/time.go +++ b/dialects/time.go @@ -18,8 +18,13 @@ 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. - if dialect.URI().DBType == schemas.ORACLE { + case schemas.Varchar: // !DarthPestilane! format time when sqlTypeName is schemas.Varchar. + v = t.Format("2006-01-02 15:04:05") + case schemas.TimeStamp, schemas.DateTime: + dbType := dialect.URI().DBType + if dbType == schemas.POSTGRES || dbType == schemas.MYSQL { + v = t.Format("2006-01-02 15:04:05.999999") + } else if dialect.URI().DBType == schemas.ORACLE { v = t } else { v = t.Format("2006-01-02 15:04:05")