sea-orm/sea-orm-codegen/tests/compact/cake_filling_price.rs
Billy Chan 9d033d01a8
Fix: generate relation for related entity of composite foreign key (#1693)
* Fix: generate relation for related entity of composite foreign key

* clippy
2023-09-22 02:28:49 +08:00

31 lines
880 B
Rust

//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "cake_filling_price")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub cake_id: i32,
#[sea_orm(primary_key, auto_increment = false)]
pub filling_id: i32,
pub price: Decimal,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::cake_filling::Entity",
from = "(Column::CakeId, Column::FillingId)",
to = "(super::cake_filling::Column::CakeId, super::cake_filling::Column::FillingId)",
)]
CakeFilling,
}
impl Related<super::cake_filling::Entity> for Entity {
fn to() -> RelationDef {
Relation::CakeFilling.def()
}
}
impl ActiveModelBehavior for ActiveModel {}