From 116083179055b38fea12d1621f96dfcdd906b3f6 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Fri, 17 Dec 2021 17:49:14 +0800 Subject: [PATCH] Add SQLite "sakila.db" demo [issues] --- .github/workflows/rust.yml | 2 +- issues/386/Cargo.toml | 11 +++++ issues/386/src/main.rs | 3 ++ issues/386/src/out/actor.rs | 27 ++++++++++ issues/386/src/out/address.rs | 61 +++++++++++++++++++++++ issues/386/src/out/category.rs | 30 ++++++++++++ issues/386/src/out/city.rs | 42 ++++++++++++++++ issues/386/src/out/country.rs | 30 ++++++++++++ issues/386/src/out/customer.rs | 69 ++++++++++++++++++++++++++ issues/386/src/out/film.rs | 75 ++++++++++++++++++++++++++++ issues/386/src/out/film_actor.rs | 47 ++++++++++++++++++ issues/386/src/out/film_category.rs | 51 +++++++++++++++++++ issues/386/src/out/film_text.rs | 28 +++++++++++ issues/386/src/out/inventory.rs | 55 +++++++++++++++++++++ issues/386/src/out/language.rs | 28 +++++++++++ issues/386/src/out/mod.rs | 20 ++++++++ issues/386/src/out/payment.rs | 66 +++++++++++++++++++++++++ issues/386/src/out/prelude.rs | 18 +++++++ issues/386/src/out/rental.rs | 73 +++++++++++++++++++++++++++ issues/386/src/out/staff.rs | 76 +++++++++++++++++++++++++++++ issues/386/src/out/store.rs | 64 ++++++++++++++++++++++++ 21 files changed, 875 insertions(+), 1 deletion(-) create mode 100644 issues/386/Cargo.toml create mode 100644 issues/386/src/main.rs create mode 100644 issues/386/src/out/actor.rs create mode 100644 issues/386/src/out/address.rs create mode 100644 issues/386/src/out/category.rs create mode 100644 issues/386/src/out/city.rs create mode 100644 issues/386/src/out/country.rs create mode 100644 issues/386/src/out/customer.rs create mode 100644 issues/386/src/out/film.rs create mode 100644 issues/386/src/out/film_actor.rs create mode 100644 issues/386/src/out/film_category.rs create mode 100644 issues/386/src/out/film_text.rs create mode 100644 issues/386/src/out/inventory.rs create mode 100644 issues/386/src/out/language.rs create mode 100644 issues/386/src/out/mod.rs create mode 100644 issues/386/src/out/payment.rs create mode 100644 issues/386/src/out/prelude.rs create mode 100644 issues/386/src/out/rental.rs create mode 100644 issues/386/src/out/staff.rs create mode 100644 issues/386/src/out/store.rs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4affff6621..b961890481 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -316,7 +316,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - path: [86, 249, 262, 319, 324, 352, 356] + path: [86, 249, 262, 319, 324, 352, 356, 386] steps: - uses: actions/checkout@v2 diff --git a/issues/386/Cargo.toml b/issues/386/Cargo.toml new file mode 100644 index 0000000000..f3a975f16e --- /dev/null +++ b/issues/386/Cargo.toml @@ -0,0 +1,11 @@ +[workspace] +# A separate workspace + +[package] +name = "sea-orm-issues-386" +version = "0.1.0" +edition = "2021" +publish = false + +[dependencies] +sea-orm = { path = "../../", features = [ "sqlx-mysql", "runtime-async-std-native-tls" ]} diff --git a/issues/386/src/main.rs b/issues/386/src/main.rs new file mode 100644 index 0000000000..7c815e0adb --- /dev/null +++ b/issues/386/src/main.rs @@ -0,0 +1,3 @@ +mod out; + +pub fn main() {} diff --git a/issues/386/src/out/actor.rs b/issues/386/src/out/actor.rs new file mode 100644 index 0000000000..ad7248d620 --- /dev/null +++ b/issues/386/src/out/actor.rs @@ -0,0 +1,27 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "actor")] +pub struct Model { + #[sea_orm(primary_key)] + pub actor_id: i32, + pub first_name: String, + pub last_name: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::film_actor::Entity")] + FilmActor, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::FilmActor.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/address.rs b/issues/386/src/out/address.rs new file mode 100644 index 0000000000..04541e3cc5 --- /dev/null +++ b/issues/386/src/out/address.rs @@ -0,0 +1,61 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "address")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub address_id: i32, + pub address: String, + pub address2: Option, + pub district: String, + pub city_id: i32, + pub postal_code: Option, + pub phone: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::city::Entity", + from = "Column::CityId", + to = "super::city::Column::CityId", + on_update = "Cascade", + on_delete = "NoAction" + )] + City, + #[sea_orm(has_many = "super::customer::Entity")] + Customer, + #[sea_orm(has_many = "super::staff::Entity")] + Staff, + #[sea_orm(has_many = "super::store::Entity")] + Store, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::City.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Staff.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Store.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/category.rs b/issues/386/src/out/category.rs new file mode 100644 index 0000000000..a7ff20f379 --- /dev/null +++ b/issues/386/src/out/category.rs @@ -0,0 +1,30 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "category")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Custom(\"BLOB\".to_owned())" + )] + pub category_id: String, + pub name: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::film_category::Entity")] + FilmCategory, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::FilmCategory.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/city.rs b/issues/386/src/out/city.rs new file mode 100644 index 0000000000..02d28b0d14 --- /dev/null +++ b/issues/386/src/out/city.rs @@ -0,0 +1,42 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "city")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub city_id: i32, + pub city: String, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub country_id: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::country::Entity", + from = "Column::CountryId", + to = "super::country::Column::CountryId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Country, + #[sea_orm(has_many = "super::address::Entity")] + Address, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Country.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Address.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/country.rs b/issues/386/src/out/country.rs new file mode 100644 index 0000000000..9fe9682984 --- /dev/null +++ b/issues/386/src/out/country.rs @@ -0,0 +1,30 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "country")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Custom(\"BLOB\".to_owned())" + )] + pub country_id: String, + pub country: String, + pub last_update: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::city::Entity")] + City, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::City.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/customer.rs b/issues/386/src/out/customer.rs new file mode 100644 index 0000000000..95807b652f --- /dev/null +++ b/issues/386/src/out/customer.rs @@ -0,0 +1,69 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "customer")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub customer_id: i32, + pub store_id: i32, + pub first_name: String, + pub last_name: String, + pub email: Option, + pub address_id: i32, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub active: String, + pub create_date: DateTime, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::address::Entity", + from = "Column::AddressId", + to = "super::address::Column::AddressId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Address, + #[sea_orm( + belongs_to = "super::store::Entity", + from = "Column::StoreId", + to = "super::store::Column::StoreId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Store, + #[sea_orm(has_many = "super::payment::Entity")] + Payment, + #[sea_orm(has_many = "super::rental::Entity")] + Rental, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Address.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Store.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payment.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Rental.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/film.rs b/issues/386/src/out/film.rs new file mode 100644 index 0000000000..39cf03306d --- /dev/null +++ b/issues/386/src/out/film.rs @@ -0,0 +1,75 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "film")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub film_id: i32, + pub title: String, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())", nullable)] + pub description: Option, + pub release_year: Option, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub language_id: String, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())", nullable)] + pub original_language_id: Option, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub rental_duration: String, + #[sea_orm(column_type = "Decimal(Some((4, 2)))")] + pub rental_rate: Decimal, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())", nullable)] + pub length: Option, + #[sea_orm(column_type = "Decimal(Some((5, 2)))")] + pub replacement_cost: Decimal, + pub rating: Option, + pub special_features: Option, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::language::Entity", + from = "Column::OriginalLanguageId", + to = "super::language::Column::LanguageId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Language2, + #[sea_orm( + belongs_to = "super::language::Entity", + from = "Column::LanguageId", + to = "super::language::Column::LanguageId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Language1, + #[sea_orm(has_many = "super::film_actor::Entity")] + FilmActor, + #[sea_orm(has_many = "super::film_category::Entity")] + FilmCategory, + #[sea_orm(has_many = "super::inventory::Entity")] + Inventory, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::FilmActor.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::FilmCategory.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Inventory.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/film_actor.rs b/issues/386/src/out/film_actor.rs new file mode 100644 index 0000000000..ba23ccb774 --- /dev/null +++ b/issues/386/src/out/film_actor.rs @@ -0,0 +1,47 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "film_actor")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub actor_id: i32, + #[sea_orm(primary_key, auto_increment = false)] + pub film_id: i32, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::film::Entity", + from = "Column::FilmId", + to = "super::film::Column::FilmId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Film, + #[sea_orm( + belongs_to = "super::actor::Entity", + from = "Column::ActorId", + to = "super::actor::Column::ActorId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Actor, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Film.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Actor.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/film_category.rs b/issues/386/src/out/film_category.rs new file mode 100644 index 0000000000..222a773aad --- /dev/null +++ b/issues/386/src/out/film_category.rs @@ -0,0 +1,51 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "film_category")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub film_id: i32, + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Custom(\"BLOB\".to_owned())" + )] + pub category_id: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::category::Entity", + from = "Column::CategoryId", + to = "super::category::Column::CategoryId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Category, + #[sea_orm( + belongs_to = "super::film::Entity", + from = "Column::FilmId", + to = "super::film::Column::FilmId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Film, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Category.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Film.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/film_text.rs b/issues/386/src/out/film_text.rs new file mode 100644 index 0000000000..d8f26b6964 --- /dev/null +++ b/issues/386/src/out/film_text.rs @@ -0,0 +1,28 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "film_text")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Custom(\"BLOB\".to_owned())" + )] + pub film_id: String, + pub title: String, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())", nullable)] + pub description: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/inventory.rs b/issues/386/src/out/inventory.rs new file mode 100644 index 0000000000..2f71f5c40f --- /dev/null +++ b/issues/386/src/out/inventory.rs @@ -0,0 +1,55 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "inventory")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub inventory_id: i32, + pub film_id: i32, + pub store_id: i32, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::film::Entity", + from = "Column::FilmId", + to = "super::film::Column::FilmId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Film, + #[sea_orm( + belongs_to = "super::store::Entity", + from = "Column::StoreId", + to = "super::store::Column::StoreId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Store, + #[sea_orm(has_many = "super::rental::Entity")] + Rental, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Film.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Store.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Rental.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/language.rs b/issues/386/src/out/language.rs new file mode 100644 index 0000000000..d77db36859 --- /dev/null +++ b/issues/386/src/out/language.rs @@ -0,0 +1,28 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "language")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Custom(\"BLOB\".to_owned())" + )] + pub language_id: String, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub name: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/mod.rs b/issues/386/src/out/mod.rs new file mode 100644 index 0000000000..d7f098fca3 --- /dev/null +++ b/issues/386/src/out/mod.rs @@ -0,0 +1,20 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +pub mod prelude; + +pub mod actor; +pub mod address; +pub mod category; +pub mod city; +pub mod country; +pub mod customer; +pub mod film; +pub mod film_actor; +pub mod film_category; +pub mod film_text; +pub mod inventory; +pub mod language; +pub mod payment; +pub mod rental; +pub mod staff; +pub mod store; diff --git a/issues/386/src/out/payment.rs b/issues/386/src/out/payment.rs new file mode 100644 index 0000000000..43c494b4a9 --- /dev/null +++ b/issues/386/src/out/payment.rs @@ -0,0 +1,66 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "payment")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub payment_id: i32, + pub customer_id: i32, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub staff_id: String, + pub rental_id: Option, + #[sea_orm(column_type = "Decimal(Some((5, 2)))")] + pub amount: Decimal, + pub payment_date: DateTime, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::staff::Entity", + from = "Column::StaffId", + to = "super::staff::Column::StaffId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Staff, + #[sea_orm( + belongs_to = "super::customer::Entity", + from = "Column::CustomerId", + to = "super::customer::Column::CustomerId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Customer, + #[sea_orm( + belongs_to = "super::rental::Entity", + from = "Column::RentalId", + to = "super::rental::Column::RentalId", + on_update = "Cascade", + on_delete = "SetNull" + )] + Rental, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Staff.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Rental.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/prelude.rs b/issues/386/src/out/prelude.rs new file mode 100644 index 0000000000..85cecd8718 --- /dev/null +++ b/issues/386/src/out/prelude.rs @@ -0,0 +1,18 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +pub use super::actor::Entity as Actor; +pub use super::address::Entity as Address; +pub use super::category::Entity as Category; +pub use super::city::Entity as City; +pub use super::country::Entity as Country; +pub use super::customer::Entity as Customer; +pub use super::film::Entity as Film; +pub use super::film_actor::Entity as FilmActor; +pub use super::film_category::Entity as FilmCategory; +pub use super::film_text::Entity as FilmText; +pub use super::inventory::Entity as Inventory; +pub use super::language::Entity as Language; +pub use super::payment::Entity as Payment; +pub use super::rental::Entity as Rental; +pub use super::staff::Entity as Staff; +pub use super::store::Entity as Store; diff --git a/issues/386/src/out/rental.rs b/issues/386/src/out/rental.rs new file mode 100644 index 0000000000..15c7e9d907 --- /dev/null +++ b/issues/386/src/out/rental.rs @@ -0,0 +1,73 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "rental")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub rental_id: i32, + pub rental_date: DateTime, + pub inventory_id: i32, + pub customer_id: i32, + pub return_date: Option, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub staff_id: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::customer::Entity", + from = "Column::CustomerId", + to = "super::customer::Column::CustomerId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Customer, + #[sea_orm( + belongs_to = "super::inventory::Entity", + from = "Column::InventoryId", + to = "super::inventory::Column::InventoryId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Inventory, + #[sea_orm( + belongs_to = "super::staff::Entity", + from = "Column::StaffId", + to = "super::staff::Column::StaffId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Staff, + #[sea_orm(has_many = "super::payment::Entity")] + Payment, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Inventory.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Staff.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payment.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/staff.rs b/issues/386/src/out/staff.rs new file mode 100644 index 0000000000..805e5a26fa --- /dev/null +++ b/issues/386/src/out/staff.rs @@ -0,0 +1,76 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "staff")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Custom(\"BLOB\".to_owned())" + )] + pub staff_id: String, + pub first_name: String, + pub last_name: String, + pub address_id: i32, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())", nullable)] + pub picture: Option, + pub email: Option, + pub store_id: i32, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub active: String, + pub username: String, + pub password: Option, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::address::Entity", + from = "Column::AddressId", + to = "super::address::Column::AddressId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Address, + #[sea_orm( + belongs_to = "super::store::Entity", + from = "Column::StoreId", + to = "super::store::Column::StoreId", + on_update = "Cascade", + on_delete = "NoAction" + )] + Store, + #[sea_orm(has_many = "super::payment::Entity")] + Payment, + #[sea_orm(has_many = "super::rental::Entity")] + Rental, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Address.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Store.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payment.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Rental.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/out/store.rs b/issues/386/src/out/store.rs new file mode 100644 index 0000000000..f7e1eb4a47 --- /dev/null +++ b/issues/386/src/out/store.rs @@ -0,0 +1,64 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "store")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub store_id: i32, + #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")] + pub manager_staff_id: String, + pub address_id: i32, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::address::Entity", + from = "Column::AddressId", + to = "super::address::Column::AddressId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Address, + #[sea_orm( + belongs_to = "super::staff::Entity", + from = "Column::ManagerStaffId", + to = "super::staff::Column::StaffId", + on_update = "NoAction", + on_delete = "NoAction" + )] + Staff, + #[sea_orm(has_many = "super::customer::Entity")] + Customer, + #[sea_orm(has_many = "super::inventory::Entity")] + Inventory, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Address.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Staff.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Inventory.def() + } +} + +impl ActiveModelBehavior for ActiveModel {}