Move impl Linked
to entity_linked module
This commit is contained in:
parent
a4f2e3c2a8
commit
e558dc8584
@ -74,7 +74,7 @@ where
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::tests_cfg::{cake, cake_filling, cake_filling_price, filling, fruit};
|
use crate::tests_cfg::{cake, cake_filling, cake_filling_price, entity_linked, filling, fruit};
|
||||||
use crate::{ColumnTrait, DbBackend, EntityTrait, ModelTrait, QueryFilter, QueryTrait};
|
use crate::{ColumnTrait, DbBackend, EntityTrait, ModelTrait, QueryFilter, QueryTrait};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cake_model
|
cake_model
|
||||||
.find_linked(cake::CakeToFilling)
|
.find_linked(entity_linked::CakeToFilling)
|
||||||
.build(DbBackend::MySql)
|
.build(DbBackend::MySql)
|
||||||
.to_string(),
|
.to_string(),
|
||||||
[
|
[
|
||||||
@ -267,7 +267,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cake_model
|
cake_model
|
||||||
.find_linked(cake::CakeToFillingVendor)
|
.find_linked(entity_linked::CakeToFillingVendor)
|
||||||
.build(DbBackend::MySql)
|
.build(DbBackend::MySql)
|
||||||
.to_string(),
|
.to_string(),
|
||||||
[
|
[
|
||||||
@ -286,7 +286,7 @@ mod tests {
|
|||||||
fn join_12() {
|
fn join_12() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cake::Entity::find()
|
cake::Entity::find()
|
||||||
.find_also_linked(cake::CakeToFilling)
|
.find_also_linked(entity_linked::CakeToFilling)
|
||||||
.build(DbBackend::MySql)
|
.build(DbBackend::MySql)
|
||||||
.to_string(),
|
.to_string(),
|
||||||
[
|
[
|
||||||
@ -304,7 +304,7 @@ mod tests {
|
|||||||
fn join_13() {
|
fn join_13() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cake::Entity::find()
|
cake::Entity::find()
|
||||||
.find_also_linked(cake::CakeToFillingVendor)
|
.find_also_linked(entity_linked::CakeToFillingVendor)
|
||||||
.build(DbBackend::MySql)
|
.build(DbBackend::MySql)
|
||||||
.to_string(),
|
.to_string(),
|
||||||
[
|
[
|
||||||
|
@ -31,37 +31,4 @@ impl Related<super::filling::Entity> for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct CakeToFilling;
|
|
||||||
|
|
||||||
impl Linked for CakeToFilling {
|
|
||||||
type FromEntity = Entity;
|
|
||||||
|
|
||||||
type ToEntity = super::filling::Entity;
|
|
||||||
|
|
||||||
fn link(&self) -> Vec<RelationDef> {
|
|
||||||
vec![
|
|
||||||
super::cake_filling::Relation::Cake.def().rev(),
|
|
||||||
super::cake_filling::Relation::Filling.def(),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct CakeToFillingVendor;
|
|
||||||
|
|
||||||
impl Linked for CakeToFillingVendor {
|
|
||||||
type FromEntity = Entity;
|
|
||||||
|
|
||||||
type ToEntity = super::vendor::Entity;
|
|
||||||
|
|
||||||
fn link(&self) -> Vec<RelationDef> {
|
|
||||||
vec![
|
|
||||||
super::cake_filling::Relation::Cake.def().rev(),
|
|
||||||
super::cake_filling::Relation::Filling.def(),
|
|
||||||
super::filling::Relation::Vendor.def(),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
@ -75,20 +75,4 @@ impl Related<super::filling::Entity> for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct CakeToFilling;
|
|
||||||
|
|
||||||
impl Linked for CakeToFilling {
|
|
||||||
type FromEntity = Entity;
|
|
||||||
|
|
||||||
type ToEntity = super::filling::Entity;
|
|
||||||
|
|
||||||
fn link(&self) -> Vec<RelationDef> {
|
|
||||||
vec![
|
|
||||||
super::cake_filling::Relation::Cake.def().rev(),
|
|
||||||
super::cake_filling::Relation::Filling.def(),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
34
src/tests_cfg/entity_linked.rs
Normal file
34
src/tests_cfg/entity_linked.rs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
use crate::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct CakeToFilling;
|
||||||
|
|
||||||
|
impl Linked for CakeToFilling {
|
||||||
|
type FromEntity = super::cake::Entity;
|
||||||
|
|
||||||
|
type ToEntity = super::filling::Entity;
|
||||||
|
|
||||||
|
fn link(&self) -> Vec<RelationDef> {
|
||||||
|
vec![
|
||||||
|
super::cake_filling::Relation::Cake.def().rev(),
|
||||||
|
super::cake_filling::Relation::Filling.def(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct CakeToFillingVendor;
|
||||||
|
|
||||||
|
impl Linked for CakeToFillingVendor {
|
||||||
|
type FromEntity = super::cake::Entity;
|
||||||
|
|
||||||
|
type ToEntity = super::vendor::Entity;
|
||||||
|
|
||||||
|
fn link(&self) -> Vec<RelationDef> {
|
||||||
|
vec![
|
||||||
|
super::cake_filling::Relation::Cake.def().rev(),
|
||||||
|
super::cake_filling::Relation::Filling.def(),
|
||||||
|
super::filling::Relation::Vendor.def(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ pub mod cake;
|
|||||||
pub mod cake_expanded;
|
pub mod cake_expanded;
|
||||||
pub mod cake_filling;
|
pub mod cake_filling;
|
||||||
pub mod cake_filling_price;
|
pub mod cake_filling_price;
|
||||||
|
pub mod entity_linked;
|
||||||
pub mod filling;
|
pub mod filling;
|
||||||
pub mod fruit;
|
pub mod fruit;
|
||||||
pub mod vendor;
|
pub mod vendor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user