From c05c180cd1f2f94cbcbf851782b2dd0c9925d676 Mon Sep 17 00:00:00 2001 From: SarveshOO7 Date: Sun, 17 Nov 2024 17:47:11 -0500 Subject: [PATCH] pushing entities --- optd-persistent/src/entities/predicate.rs | 60 +++++++++++++++++++ .../src/entities/predicate_children.rs | 34 +++++++++++ .../predicate_logical_expression_junction.rs | 46 ++++++++++++++ .../predicate_physical_expression_junction.rs | 46 ++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 optd-persistent/src/entities/predicate.rs create mode 100644 optd-persistent/src/entities/predicate_children.rs create mode 100644 optd-persistent/src/entities/predicate_logical_expression_junction.rs create mode 100644 optd-persistent/src/entities/predicate_physical_expression_junction.rs diff --git a/optd-persistent/src/entities/predicate.rs b/optd-persistent/src/entities/predicate.rs new file mode 100644 index 0000000..e142a21 --- /dev/null +++ b/optd-persistent/src/entities/predicate.rs @@ -0,0 +1,60 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "predicate")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub data: Json, + pub variant: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::predicate_logical_expression_junction::Entity")] + PredicateLogicalExpressionJunction, + #[sea_orm(has_many = "super::predicate_physical_expression_junction::Entity")] + PredicatePhysicalExpressionJunction, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PredicateLogicalExpressionJunction.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PredicatePhysicalExpressionJunction.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::predicate_logical_expression_junction::Relation::LogicalExpression.def() + } + fn via() -> Option { + Some( + super::predicate_logical_expression_junction::Relation::Predicate + .def() + .rev(), + ) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::predicate_physical_expression_junction::Relation::PhysicalExpression.def() + } + fn via() -> Option { + Some( + super::predicate_physical_expression_junction::Relation::Predicate + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/optd-persistent/src/entities/predicate_children.rs b/optd-persistent/src/entities/predicate_children.rs new file mode 100644 index 0000000..93ef3eb --- /dev/null +++ b/optd-persistent/src/entities/predicate_children.rs @@ -0,0 +1,34 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "predicate_children")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub parent_id: i32, + #[sea_orm(primary_key, auto_increment = false)] + pub child_id: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::predicate::Entity", + from = "Column::ChildId", + to = "super::predicate::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Predicate2, + #[sea_orm( + belongs_to = "super::predicate::Entity", + from = "Column::ParentId", + to = "super::predicate::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Predicate1, +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/optd-persistent/src/entities/predicate_logical_expression_junction.rs b/optd-persistent/src/entities/predicate_logical_expression_junction.rs new file mode 100644 index 0000000..520da03 --- /dev/null +++ b/optd-persistent/src/entities/predicate_logical_expression_junction.rs @@ -0,0 +1,46 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "predicate_logical_expression_junction")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub logical_expr_id: i32, + #[sea_orm(primary_key, auto_increment = false)] + pub predicate_id: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::logical_expression::Entity", + from = "Column::LogicalExprId", + to = "super::logical_expression::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + LogicalExpression, + #[sea_orm( + belongs_to = "super::predicate::Entity", + from = "Column::PredicateId", + to = "super::predicate::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Predicate, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LogicalExpression.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Predicate.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/optd-persistent/src/entities/predicate_physical_expression_junction.rs b/optd-persistent/src/entities/predicate_physical_expression_junction.rs new file mode 100644 index 0000000..263abc8 --- /dev/null +++ b/optd-persistent/src/entities/predicate_physical_expression_junction.rs @@ -0,0 +1,46 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "predicate_physical_expression_junction")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub physical_expr_id: i32, + #[sea_orm(primary_key, auto_increment = false)] + pub predicate_id: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::physical_expression::Entity", + from = "Column::PhysicalExprId", + to = "super::physical_expression::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + PhysicalExpression, + #[sea_orm( + belongs_to = "super::predicate::Entity", + from = "Column::PredicateId", + to = "super::predicate::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Predicate, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PhysicalExpression.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Predicate.def() + } +} + +impl ActiveModelBehavior for ActiveModel {}