From 8f66968724e87f469e0cb0f04fd8c8d798b49c42 Mon Sep 17 00:00:00 2001 From: Sam Samai Date: Tue, 29 Jun 2021 12:03:11 +1000 Subject: [PATCH] Use find_related in place of find_xxx --- tests/bakery_chain/baker.rs | 10 ++++++++++ tests/bakery_chain/bakery.rs | 6 ------ tests/bakery_chain/cake.rs | 6 ------ tests/bakery_chain/customer.rs | 6 ------ tests/bakery_chain/lineitem.rs | 6 ------ tests/bakery_chain/order.rs | 6 ------ 6 files changed, 10 insertions(+), 30 deletions(-) diff --git a/tests/bakery_chain/baker.rs b/tests/bakery_chain/baker.rs index e5062c8e..b359e7ef 100644 --- a/tests/bakery_chain/baker.rs +++ b/tests/bakery_chain/baker.rs @@ -68,4 +68,14 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + super::cakes_bakers::Relation::Cake.def() + } + + fn via() -> Option { + Some(super::cakes_bakers::Relation::Baker.def().rev()) + } +} + impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/bakery_chain/bakery.rs b/tests/bakery_chain/bakery.rs index ff4577c8..8348a764 100644 --- a/tests/bakery_chain/bakery.rs +++ b/tests/bakery_chain/bakery.rs @@ -67,10 +67,4 @@ impl Related for Entity { } } -impl Model { - pub fn find_bakers(&self) -> Select { - Entity::find_related().belongs_to::(self) - } -} - impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/bakery_chain/cake.rs b/tests/bakery_chain/cake.rs index 976d8acb..6ba431a4 100644 --- a/tests/bakery_chain/cake.rs +++ b/tests/bakery_chain/cake.rs @@ -98,10 +98,4 @@ impl Related for Entity { } } -impl Model { - pub fn find_bakers(&self) -> Select { - Entity::find_related().belongs_to::(self) - } -} - impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/bakery_chain/customer.rs b/tests/bakery_chain/customer.rs index edbd9311..d8566726 100644 --- a/tests/bakery_chain/customer.rs +++ b/tests/bakery_chain/customer.rs @@ -68,10 +68,4 @@ impl Related for Entity { } } -impl Model { - pub fn find_orders(&self) -> Select { - Entity::find_related().belongs_to::(self) - } -} - impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/bakery_chain/lineitem.rs b/tests/bakery_chain/lineitem.rs index 261de494..9dc7e096 100644 --- a/tests/bakery_chain/lineitem.rs +++ b/tests/bakery_chain/lineitem.rs @@ -71,10 +71,4 @@ impl Related for Entity { } } -impl Model { - pub fn find_orders(&self) -> Select { - Entity::find_related().belongs_to::(self) - } -} - impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/bakery_chain/order.rs b/tests/bakery_chain/order.rs index ff655699..f18c3a3b 100644 --- a/tests/bakery_chain/order.rs +++ b/tests/bakery_chain/order.rs @@ -93,10 +93,4 @@ impl Related for Entity { } } -impl Model { - pub fn find_lineitems(&self) -> Select { - Entity::find_related().belongs_to::(self) - } -} - impl ActiveModelBehavior for ActiveModel {}