Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Dec 14, 2023
1 parent 91b6f79 commit 8a29cba
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub user_id: Option<i32> ,
pub user_id: Option<i32>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand All @@ -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")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ pub enum Relation {
from = "Column::BillId",
to = "super::bills::Column::Id",
on_update = "Cascade",
on_delete = "Cascade",
on_delete = "Cascade"
)]
Bills,
#[sea_orm(
belongs_to = "super::users::Entity",
from = "Column::UserId",
to = "super::users::Column::Id",
on_update = "Cascade",
on_delete = "Cascade",
on_delete = "Cascade"
)]
Users,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ pub enum Relation {
from = "Column::BillId",
to = "super::bills::Column::Id",
on_update = "Cascade",
on_delete = "Cascade",
on_delete = "Cascade"
)]
Bills,
#[sea_orm(
belongs_to = "super::users::Entity",
from = "Column::UserId",
to = "super::users::Column::Id",
on_update = "Cascade",
on_delete = "Cascade",
on_delete = "Cascade"
)]
Users,
}
Expand Down
4 changes: 2 additions & 2 deletions sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub user_id: Option<i32> ,
pub user_id: Option<i32>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand All @@ -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")]
Expand Down
4 changes: 2 additions & 2 deletions sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ pub enum Relation {
from = "Column::BillId",
to = "super::bills::Column::Id",
on_update = "Cascade",
on_delete = "Cascade",
on_delete = "Cascade"
)]
Bills,
#[sea_orm(
belongs_to = "super::users::Entity",
from = "Column::UserId",
to = "super::users::Column::Id",
on_update = "Cascade",
on_delete = "Cascade",
on_delete = "Cascade"
)]
Users,
}
Expand Down
4 changes: 2 additions & 2 deletions sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub user_id: Option<i32> ,
pub user_id: Option<i32>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand All @@ -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,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<i32> ,
pub bill_idd: Option<i32> ,
pub user_idd: Option<i32>,
pub bill_idd: Option<i32>,
pub vote: bool,
}

Expand All @@ -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,
}
Expand Down
8 changes: 2 additions & 6 deletions sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub self_id: Option<i32> ,
pub self_id: Option<i32>,
}

#[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,
}

Expand Down
16 changes: 4 additions & 12 deletions sea-orm-codegen/src/tests_cfg/self_referencing/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub self_id: Option<i32> ,
pub self_idd: Option<i32> ,
pub self_id: Option<i32>,
pub self_idd: Option<i32>,
}

#[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,
}

Expand Down
2 changes: 2 additions & 0 deletions tests/active_enum_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8a29cba

Please sign in to comment.