Skip to content

Commit

Permalink
pushing entities
Browse files Browse the repository at this point in the history
  • Loading branch information
SarveshOO7 committed Nov 17, 2024
1 parent 1fcef01 commit c05c180
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 0 deletions.
60 changes: 60 additions & 0 deletions optd-persistent/src/entities/predicate.rs
Original file line number Diff line number Diff line change
@@ -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<super::predicate_logical_expression_junction::Entity> for Entity {
fn to() -> RelationDef {
Relation::PredicateLogicalExpressionJunction.def()
}
}

impl Related<super::predicate_physical_expression_junction::Entity> for Entity {
fn to() -> RelationDef {
Relation::PredicatePhysicalExpressionJunction.def()
}
}

impl Related<super::logical_expression::Entity> for Entity {
fn to() -> RelationDef {
super::predicate_logical_expression_junction::Relation::LogicalExpression.def()
}
fn via() -> Option<RelationDef> {
Some(
super::predicate_logical_expression_junction::Relation::Predicate
.def()
.rev(),
)
}
}

impl Related<super::physical_expression::Entity> for Entity {
fn to() -> RelationDef {
super::predicate_physical_expression_junction::Relation::PhysicalExpression.def()
}
fn via() -> Option<RelationDef> {
Some(
super::predicate_physical_expression_junction::Relation::Predicate
.def()
.rev(),
)
}
}

impl ActiveModelBehavior for ActiveModel {}
34 changes: 34 additions & 0 deletions optd-persistent/src/entities/predicate_children.rs
Original file line number Diff line number Diff line change
@@ -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 {}
Original file line number Diff line number Diff line change
@@ -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<super::logical_expression::Entity> for Entity {
fn to() -> RelationDef {
Relation::LogicalExpression.def()
}
}

impl Related<super::predicate::Entity> for Entity {
fn to() -> RelationDef {
Relation::Predicate.def()
}
}

impl ActiveModelBehavior for ActiveModel {}
Original file line number Diff line number Diff line change
@@ -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<super::physical_expression::Entity> for Entity {
fn to() -> RelationDef {
Relation::PhysicalExpression.def()
}
}

impl Related<super::predicate::Entity> for Entity {
fn to() -> RelationDef {
Relation::Predicate.def()
}
}

impl ActiveModelBehavior for ActiveModel {}

0 comments on commit c05c180

Please sign in to comment.