Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimeUtc is recognized as TimestampWithTimeZone #2090

Open
xtexChooser opened this issue Jan 31, 2024 · 1 comment
Open

DateTimeUtc is recognized as TimestampWithTimeZone #2090

xtexChooser opened this issue Jan 31, 2024 · 1 comment

Comments

@xtexChooser
Copy link

As the document:
image
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.

@tyt2y3
Copy link
Member

tyt2y3 commented Mar 2, 2024

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.

xtexChooser added a commit to xtexChooser/central that referenced this issue May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants