* sqlite: deps * sqlite: update data type mappings * sqlite: decimal test cases * sqlite: try negative numbers * fixup * fixup * fmt * clippy * fixup * fixup * fixup * refactor * fix * Drop the use of `rust_decimal_macros` (#2078) * sqlite: decimal -> real * revert * Bump dependencies * Fixup * Fixup * Fixup * Fixup * Refactor * Refactor * Refactor
77 lines
1.6 KiB
Rust
77 lines
1.6 KiB
Rust
//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0
|
|
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
|
|
pub struct Entity;
|
|
|
|
impl EntityName for Entity {
|
|
fn table_name(&self) -> &str {
|
|
"vendor"
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)]
|
|
pub struct Model {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub fruit_id: Option<i32> ,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
|
pub enum Column {
|
|
Id,
|
|
#[sea_orm(column_name = "_name_")]
|
|
Name,
|
|
#[sea_orm(column_name = "fruitId")]
|
|
FruitId,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
|
pub enum PrimaryKey {
|
|
Id,
|
|
}
|
|
|
|
impl PrimaryKeyTrait for PrimaryKey {
|
|
type ValueType = i32;
|
|
|
|
fn auto_increment() -> bool {
|
|
true
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
|
pub enum Relation {
|
|
Fruit,
|
|
}
|
|
|
|
impl ColumnTrait for Column {
|
|
type EntityName = Entity;
|
|
fn def(&self) -> ColumnDef {
|
|
match self {
|
|
Self::Id => ColumnType::Integer.def(),
|
|
Self::Name => ColumnType::string(Some(255u32)).def(),
|
|
Self::FruitId => ColumnType::Integer.def().null(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl RelationTrait for Relation {
|
|
fn def(&self) -> RelationDef {
|
|
match self {
|
|
Self::Fruit => Entity::belongs_to(super::fruit::Entity)
|
|
.from(Column::FruitId)
|
|
.to(super::fruit::Column::Id)
|
|
.into(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Related<super::fruit::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Fruit.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|