DateTimeUtc is recognized as TimestampWithTimeZone
xtexChooser opened this issue · 1 comments
As the document:
DateTimeUtc
should be regarded as Timestamp, however, it is regarded as TimestampWithTimeZone
From the following Model:
#[sea_orm(column_type = "Timestamp", nullable, default_value = "None")]
pub col: Option<DateTimeUtc>,
I can get this error: Query Error: error occurred while decoding column \"col\": mismatched types; Rust type core::option::Option<chrono::datetime::DateTime<chrono::offset::utc::Utc>> (as SQL type TIMESTAMPTZ) is not compatible with SQL type TIMESTAMP
On PostgresQL, TIMESTAMP is the same as DATETIME. col
, which is with Timestamp column type, should be decoded as the same as DateTime
.
However the current behaviour should be kept when using with MySQL.
I see, but sadly in Entity definition there is no way to know whether it is MySQL or Postgres. MySQL does not have timestamptz. But I do think we can specifically convert Timestamp to DateTime<Utc>
on the MySQL connector (it's the same data with a different type hint, afterall).
PR would be appreciated.