-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
Postgres timestamp column type #586
Comments
Hey @hf29h8sh321, thanks for the report! I guess you are on PostgreSQL database? |
I could not reproduce the error.
create table satellite
(
id bigserial
primary key,
satellite_name varchar not null,
launch_date timestamp not null,
deployment_date timestamp with time zone not null
);
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "satellite")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub satellite_name: String,
#[sea_orm(default_value = "2022-01-26 16:24:00")]
pub launch_date: DateTimeUtc,
#[sea_orm(default_value = "2022-01-26 16:24:00")]
pub deployment_date: DateTimeLocal,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}
pub async fn create_satellites_log(db: &DatabaseConnection) -> Result<(), DbErr> {
let archive = satellite::Model {
id: 3,
satellite_name: "Sea-00001-2022".to_owned(),
launch_date: "2022-01-07T12:11:23Z".parse().unwrap(),
deployment_date: "2022-01-07T12:11:23Z".parse().unwrap(),
};
let res = Satellite::insert(archive.clone().into_active_model())
.exec(db)
.await?;
assert_eq!(archive.id, res.last_insert_id);
assert_eq!(Satellite::find().one(db).await?, Some(archive.clone()));
Ok(())
} |
It seems like that column type is not compatible with struct field type |
I've been looking at #586 and I've also encountered this error before, also using Postgres. If I remember correctly, the issue was that I declared the column type as a DateTime using Originally posted by Galestrike#8814 on Discord |
Then, SeaSchema discover and write the column type as Finally, SeaORM codegen write Rust type of
|
I believe the issue is related to a column without |
use here is my reproduce step: SeaQL/sea-schema#50 |
Hello! I had this same issue:
But then generated entities places DateTimeUtc and after I face this:
And I no longer can query those tables with timestamp. I also had a LEFT JOIN that was returning Vec[] empty without crashing just because of that timestamp A workaround I am testing is to change the DateTimeUtc to DateTime which is chrono::NaiveDateTime and I am filling that field with but now I can query those data, even the LEFT JOIN now works. How is the status of this issue? |
Hey everyone, The root cause of it comes from SQLx:
But still we could "fix" it. For PostgreSQL: datetime (timestamp without time zone) and timestamp (timestamp) datatypes are essentially the same.
I'm going to update PostgreSQL writer on SeaSchema and mapping datetime and timestamp columns to |
Hey @ricardoalcantara, please check #772 |
Description
Steps to Reproduce
timestamp
Behavior
Reproduces How Often
Always
Versions
Postgres 14.1
The text was updated successfully, but these errors were encountered: