SeaQL / SeaQL/sea-orm

DateTimeUtc is recognized as TimestampWithTimeZone

Open
#2,090 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:type-map Category:enhancement
Dominant language
Rust
Stars
9.9k
Forks
735
Avg merge
6h 36m
Merged PRs (30d)
8

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the column_type = "Timestamp" model attribute and DateTimeUtc are mapped and decoded for PostgreSQL and MySQL. Add regression coverage for the PostgreSQL TIMESTAMP case while preserving the existing MySQL behavior; the mismatch error in the issue provides the completion criterion.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, postgresql, rust
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.