diff --git a/tests/common/bakery_chain/log.rs b/tests/common/bakery_chain/applog.rs similarity index 62% rename from tests/common/bakery_chain/log.rs rename to tests/common/bakery_chain/applog.rs index c483e41b..03b06d61 100644 --- a/tests/common/bakery_chain/log.rs +++ b/tests/common/bakery_chain/applog.rs @@ -1,7 +1,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] -#[sea_orm(table_name = "log")] +#[sea_orm(table_name = "applog")] pub struct Model { #[sea_orm(primary_key)] pub id: i32, @@ -9,13 +9,7 @@ pub struct Model { pub created_at: DateTimeWithTimeZone, } -#[derive(Copy, Clone, Debug, EnumIter)] +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation {} -impl RelationTrait for Relation { - fn def(&self) -> RelationDef { - unreachable!() - } -} - impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/common/bakery_chain/mod.rs b/tests/common/bakery_chain/mod.rs index dc145d36..36f2a16e 100644 --- a/tests/common/bakery_chain/mod.rs +++ b/tests/common/bakery_chain/mod.rs @@ -1,19 +1,19 @@ +pub mod applog; pub mod baker; pub mod bakery; pub mod cake; pub mod cakes_bakers; pub mod customer; pub mod lineitem; -pub mod log; pub mod metadata; pub mod order; +pub use super::applog::Entity as Applog; pub use super::baker::Entity as Baker; pub use super::bakery::Entity as Bakery; pub use super::cake::Entity as Cake; pub use super::cakes_bakers::Entity as CakesBakers; pub use super::customer::Entity as Customer; pub use super::lineitem::Entity as Lineitem; -pub use super::log::Entity as Log; pub use super::metadata::Entity as Metadata; pub use super::order::Entity as Order; diff --git a/tests/common/setup/schema.rs b/tests/common/setup/schema.rs index bbb09a0a..d2f3b818 100644 --- a/tests/common/setup/schema.rs +++ b/tests/common/setup/schema.rs @@ -289,22 +289,22 @@ pub async fn create_metadata_table(db: &DbConn) -> Result { pub async fn create_log_table(db: &DbConn) -> Result { let stmt = sea_query::Table::create() - .table(log::Entity) + .table(applog::Entity) .if_not_exists() .col( - ColumnDef::new(log::Column::Id) + ColumnDef::new(applog::Column::Id) .integer() .not_null() .auto_increment() .primary_key(), ) - .col(ColumnDef::new(log::Column::Json).json().not_null()) + .col(ColumnDef::new(applog::Column::Json).json().not_null()) .col( - ColumnDef::new(log::Column::CreatedAt) + ColumnDef::new(applog::Column::CreatedAt) .timestamp_with_time_zone() .not_null(), ) .to_owned(); - create_table(db, &stmt, Log).await + create_table(db, &stmt, Applog).await } diff --git a/tests/timestamp_tests.rs b/tests/timestamp_tests.rs index 6f863b2b..1897323c 100644 --- a/tests/timestamp_tests.rs +++ b/tests/timestamp_tests.rs @@ -7,27 +7,25 @@ use sea_orm::{entity::prelude::*, DatabaseConnection, IntoActiveModel}; #[cfg(feature = "sqlx-postgres")] async fn main() -> Result<(), DbErr> { let ctx = TestContext::new("bakery_chain_schema_timestamp_tests").await; - - create_log(&ctx.db).await?; - + create_applog(&ctx.db).await?; ctx.delete().await; Ok(()) } -pub async fn create_log(db: &DatabaseConnection) -> Result<(), DbErr> { - let log = log::Model { +pub async fn create_applog(db: &DatabaseConnection) -> Result<(), DbErr> { + let log = applog::Model { id: 1, json: Json::String("HI".to_owned()), created_at: "2021-09-17T17:50:20+08:00".parse().unwrap(), }; - let res = Log::insert(log.clone().into_active_model()) + let res = Applog::insert(log.clone().into_active_model()) .exec(db) .await?; assert_eq!(log.id.clone(), res.last_insert_id); - assert_eq!(Log::find().one(db).await?, Some(log.clone())); + assert_eq!(Applog::find().one(db).await?, Some(log.clone())); Ok(()) }