From b8a7ae73518b8f667e6f6cc9c3d474bf700e0c83 Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Sun, 6 Feb 2022 21:52:08 +0800 Subject: [PATCH] Revert "Insert Default - Inserting `ActiveModel` with all attributes `NotSet` (#432)" This reverts commit 33a87d79b1a789e8b47ed21bf22384289af7a487. --- tests/common/features/insert_default.rs | 13 --------- tests/common/features/mod.rs | 2 -- tests/common/features/schema.rs | 16 ---------- tests/insert_default_tests.rs | 39 ------------------------- 4 files changed, 70 deletions(-) delete mode 100644 tests/common/features/insert_default.rs delete mode 100644 tests/insert_default_tests.rs diff --git a/tests/common/features/insert_default.rs b/tests/common/features/insert_default.rs deleted file mode 100644 index 166856f64..000000000 --- a/tests/common/features/insert_default.rs +++ /dev/null @@ -1,13 +0,0 @@ -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] -#[sea_orm(table_name = "insert_default")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i32, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/common/features/mod.rs b/tests/common/features/mod.rs index d316357e2..18c0ae78a 100644 --- a/tests/common/features/mod.rs +++ b/tests/common/features/mod.rs @@ -2,7 +2,6 @@ pub mod active_enum; pub mod active_enum_child; pub mod applog; pub mod byte_primary_key; -pub mod insert_default; pub mod metadata; pub mod repository; pub mod satellite; @@ -14,7 +13,6 @@ pub use active_enum::Entity as ActiveEnum; pub use active_enum_child::Entity as ActiveEnumChild; pub use applog::Entity as Applog; pub use byte_primary_key::Entity as BytePrimaryKey; -pub use insert_default::Entity as InsertDefault; pub use metadata::Entity as Metadata; pub use repository::Entity as Repository; pub use satellite::Entity as Satellite; diff --git a/tests/common/features/schema.rs b/tests/common/features/schema.rs index f58aa6ae3..c15192535 100644 --- a/tests/common/features/schema.rs +++ b/tests/common/features/schema.rs @@ -37,7 +37,6 @@ pub async fn create_tables(db: &DatabaseConnection) -> Result<(), DbErr> { create_active_enum_table(db).await?; create_active_enum_child_table(db).await?; - create_insert_default_table(db).await?; Ok(()) } @@ -235,18 +234,3 @@ pub async fn create_satellites_table(db: &DbConn) -> Result { create_table(db, &stmt, Satellite).await } - -pub async fn create_insert_default_table(db: &DbConn) -> Result { - let create_table_stmt = sea_query::Table::create() - .table(insert_default::Entity.table_ref()) - .col( - ColumnDef::new(insert_default::Column::Id) - .integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .to_owned(); - - create_table(db, &create_table_stmt, InsertDefault).await -} diff --git a/tests/insert_default_tests.rs b/tests/insert_default_tests.rs deleted file mode 100644 index 648a11464..000000000 --- a/tests/insert_default_tests.rs +++ /dev/null @@ -1,39 +0,0 @@ -pub mod common; - -pub use common::{features::*, setup::*, TestContext}; -use pretty_assertions::assert_eq; -use sea_orm::entity::prelude::*; - -#[sea_orm_macros::test] -#[cfg(any( - feature = "sqlx-mysql", - feature = "sqlx-sqlite", - feature = "sqlx-postgres" -))] -async fn main() -> Result<(), DbErr> { - let ctx = TestContext::new("insert_default_tests").await; - create_tables(&ctx.db).await?; - create_insert_default(&ctx.db).await?; - ctx.delete().await; - - Ok(()) -} - -pub async fn create_insert_default(db: &DatabaseConnection) -> Result<(), DbErr> { - use insert_default::*; - - let active_model = ActiveModel { - ..Default::default() - }; - - active_model.clone().insert(db).await?; - active_model.clone().insert(db).await?; - active_model.insert(db).await?; - - assert_eq!( - Entity::find().all(db).await?, - vec![Model { id: 1 }, Model { id: 2 }, Model { id: 3 }] - ); - - Ok(()) -}