Skip to content

Codegen PostgreSQL timestamp column maps to NaiveDateTime in Rust#772

Closed
billy1624 wants to merge 1 commit intomasterfrom
codegen-pg-timestamp-col
Closed

Codegen PostgreSQL timestamp column maps to NaiveDateTime in Rust#772
billy1624 wants to merge 1 commit intomasterfrom
codegen-pg-timestamp-col

Conversation

@billy1624
Copy link
Copy Markdown
Member

@billy1624 billy1624 commented May 27, 2022

PR Info

With following table schema:

create table satellite
(
    id              serial primary key,
    satellite_name  varchar                                                                             not null,
    launch_date     timestamp                not null,
    deployment_date timestamp with time zone not null
);

The generated SeaORM model would be:

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "satellite")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub satellite_name: String,
    pub launch_date: DateTime,
    pub deployment_date: DateTimeWithTimeZone,
}

We still have one problem to solve. Model field defined in DateTime is assumed to be of ColumnType::DateTime instead of ColumnType::Timestamp.

"DateTime" | "NaiveDateTime" => {
quote! { DateTime }
}

I think we can still merge this but we need to clearly mention this compatibility issue on SeaORM docs. @tyt2y3

@billy1624 billy1624 self-assigned this May 27, 2022
@billy1624 billy1624 marked this pull request as ready for review May 27, 2022 08:35
@billy1624 billy1624 requested a review from tyt2y3 May 27, 2022 08:35
@tyt2y3
Copy link
Copy Markdown
Member

tyt2y3 commented Jun 30, 2022

This will be addressed by upgrading sea-schema to 0.9

@tyt2y3 tyt2y3 closed this Jun 30, 2022
@tyt2y3
Copy link
Copy Markdown
Member

tyt2y3 commented Jun 30, 2022

Docs welcomed on another PR though

billy1624 added a commit to SeaQL/seaql.github.io that referenced this pull request Jul 12, 2022
tyt2y3 added a commit to SeaQL/seaql.github.io that referenced this pull request Jul 17, 2022
* Custom join condition (SeaQL/sea-orm#793)

* Migration does not depend on entity crate

* Define integer enum with repr[x] syntax

* Document datatype mappings (SeaQL/sea-orm#772)

* Cursor pagination (SeaQL/sea-orm#754, SeaQL/sea-orm#822)

* (de)serialize custom JSON types (SeaQL/sea-orm#794)

* Generate new migration file (SeaQL/sea-orm#656)

* Skip generating entity file for specific tables (SeaQL/sea-orm#837)

* Generate entity with date time crate option (SeaQL/sea-orm#724)

* Drop `SelectTwoMany::one()` method (SeaQL/sea-orm#813)

* Datatype mappings of primitives (SeaQL/sea-orm#850, SeaQL/sea-schema#75)

* Join with table alias (SeaQL/sea-orm#852)

* SQLx logging level (SeaQL/sea-orm#800)

* Insert with on conflict (SeaQL/sea-orm#791)

* Migrate generate should take file name as argument instead of option (SeaQL/sea-orm#870)

* Upgrade docusaurus to 2.0.0-beta.22

* What's new in SeaORM 0.9.0

* Move migration section forward

* Rename "Generating Database Schema" section to "Generating SeaQuery Statement"

* Fix broken links

* Edit

* Edit

* Edit

* Edit

Co-authored-by: Chris Tsang <[email protected]>
@tyt2y3 tyt2y3 deleted the codegen-pg-timestamp-col branch July 7, 2023 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Postgres timestamp column type

2 participants