From 8a29cba78a45fc6c7fa578dfb0163ec44a77de98 Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Thu, 14 Dec 2023 20:03:02 +0000 Subject: [PATCH] Fixup --- .../duplicated_many_to_many_paths/bills.rs | 4 ++-- .../users_saved_bills.rs | 4 ++-- .../duplicated_many_to_many_paths/users_votes.rs | 4 ++-- .../src/tests_cfg/many_to_many/bills.rs | 4 ++-- .../src/tests_cfg/many_to_many/users_votes.rs | 4 ++-- .../src/tests_cfg/many_to_many_multiple/bills.rs | 4 ++-- .../many_to_many_multiple/users_votes.rs | 12 ++++++------ .../src/tests_cfg/self_referencing/bills.rs | 8 ++------ .../src/tests_cfg/self_referencing/users.rs | 16 ++++------------ tests/active_enum_tests.rs | 2 ++ 10 files changed, 26 insertions(+), 36 deletions(-) diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs index a3a6911b9..baf33426e 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option , + pub user_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction", + on_delete = "NoAction" )] Users, #[sea_orm(has_many = "super::users_saved_bills::Entity")] diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs index 4ef0281cd..575bac58f 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs @@ -16,7 +16,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Bills, #[sea_orm( @@ -24,7 +24,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs index a04ad7fa7..62f9cf7d0 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs @@ -17,7 +17,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Bills, #[sea_orm( @@ -25,7 +25,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs b/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs index 5a3acef9c..f2de469f0 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option , + pub user_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction", + on_delete = "NoAction" )] Users, #[sea_orm(has_many = "super::users_votes::Entity")] diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs b/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs index a04ad7fa7..62f9cf7d0 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs @@ -17,7 +17,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Bills, #[sea_orm( @@ -25,7 +25,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs index 5094e5885..6874aeed0 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option , + pub user_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction", + on_delete = "NoAction" )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs index 87187f4c0..29fb173cb 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs @@ -7,8 +7,8 @@ pub struct Model { pub user_id: i32, #[sea_orm(primary_key, auto_increment = false)] pub bill_id: i32, - pub user_idd: Option , - pub bill_idd: Option , + pub user_idd: Option, + pub bill_idd: Option, pub vote: bool, } @@ -17,25 +17,25 @@ pub enum Relation { #[sea_orm( belongs_to = "super::bills::Entity", from = "Column::BillIdd", - to = "super::bills::Column::Id", + to = "super::bills::Column::Id" )] Bills2, #[sea_orm( belongs_to = "super::bills::Entity", from = "Column::BillId", - to = "super::bills::Column::Id", + to = "super::bills::Column::Id" )] Bills1, #[sea_orm( belongs_to = "super::users::Entity", from = "Column::UserIdd", - to = "super::users::Column::Id", + to = "super::users::Column::Id" )] Users2, #[sea_orm( belongs_to = "super::users::Entity", from = "Column::UserId", - to = "super::users::Column::Id", + to = "super::users::Column::Id" )] Users1, } diff --git a/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs b/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs index 583655f67..22cfc4690 100644 --- a/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs @@ -5,16 +5,12 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub self_id: Option , + pub self_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm( - belongs_to = "Entity", - from = "Column::SelfId", - to = "Column::Id", - )] + #[sea_orm(belongs_to = "Entity", from = "Column::SelfId", to = "Column::Id")] SelfRef, } diff --git a/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs b/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs index b54f3e5e2..487ba9409 100644 --- a/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs +++ b/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs @@ -5,23 +5,15 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub self_id: Option , - pub self_idd: Option , + pub self_id: Option, + pub self_idd: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm( - belongs_to = "Entity", - from = "Column::SelfId", - to = "Column::Id", - )] + #[sea_orm(belongs_to = "Entity", from = "Column::SelfId", to = "Column::Id")] SelfRef2, - #[sea_orm( - belongs_to = "Entity", - from = "Column::SelfIdd", - to = "Column::Id", - )] + #[sea_orm(belongs_to = "Entity", from = "Column::SelfIdd", to = "Column::Id")] SelfRef1, } diff --git a/tests/active_enum_tests.rs b/tests/active_enum_tests.rs index e06e0ab24..1a38f3b71 100644 --- a/tests/active_enum_tests.rs +++ b/tests/active_enum_tests.rs @@ -113,6 +113,7 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> { // Equivalent to the above. let select_with_tea_in = Entity::find().filter(Column::Tea.is_in([Tea::EverydayTea, Tea::BreakfastTea])); + #[cfg(feature = "sqlx-postgres")] assert_eq!( select_with_tea_in .build(sea_orm::DatabaseBackend::Postgres) @@ -145,6 +146,7 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> { let select_with_tea_not_in = Entity::find() .filter(Column::Tea.is_not_null()) .filter(Column::Tea.is_not_in([Tea::BreakfastTea])); + #[cfg(feature = "sqlx-postgres")] assert_eq!( select_with_tea_not_in .build(sea_orm::DatabaseBackend::Postgres)