diff --git a/tests/bakery_chain/bakery.rs b/tests/bakery_chain/bakery.rs index 8348a764..61803329 100644 --- a/tests/bakery_chain/bakery.rs +++ b/tests/bakery_chain/bakery.rs @@ -38,6 +38,7 @@ impl PrimaryKeyTrait for PrimaryKey { pub enum Relation { Baker, Order, + Cake, } impl ColumnTrait for Column { @@ -57,6 +58,7 @@ impl RelationTrait for Relation { match self { Self::Baker => Entity::has_many(super::baker::Entity).into(), Self::Order => Entity::has_many(super::order::Entity).into(), + Self::Cake => Entity::has_many(super::cake::Entity).into(), } } } @@ -67,4 +69,16 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::Order.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Cake.def() + } +} + impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/bakery_chain/cake.rs b/tests/bakery_chain/cake.rs index 6ba431a4..6b18c2a0 100644 --- a/tests/bakery_chain/cake.rs +++ b/tests/bakery_chain/cake.rs @@ -98,4 +98,10 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::Lineitem.def() + } +} + impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/bakery_chain/lineitem.rs b/tests/bakery_chain/lineitem.rs index 9dc7e096..8afee4c3 100644 --- a/tests/bakery_chain/lineitem.rs +++ b/tests/bakery_chain/lineitem.rs @@ -39,6 +39,7 @@ impl PrimaryKeyTrait for PrimaryKey { #[derive(Copy, Clone, Debug, EnumIter)] pub enum Relation { Order, + Cake, } impl ColumnTrait for Column { @@ -61,6 +62,10 @@ impl RelationTrait for Relation { .from(Column::Id) .to(super::order::Column::CustomerId) .into(), + Self::Cake => Entity::belongs_to(super::cake::Entity) + .from(Column::Id) + .to(super::cake::Column::LineitemId) + .into(), } } } @@ -71,4 +76,10 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::Cake.def() + } +} + impl ActiveModelBehavior for ActiveModel {}