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/compact/actor.rs b/issues/386/src/compact/actor.rs new file mode 100644 index 0000000000..ad7248d620 --- /dev/null +++ b/issues/386/src/compact/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/compact/address.rs b/issues/386/src/compact/address.rs new file mode 100644 index 0000000000..04541e3cc5 --- /dev/null +++ b/issues/386/src/compact/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/compact/category.rs b/issues/386/src/compact/category.rs new file mode 100644 index 0000000000..a7ff20f379 --- /dev/null +++ b/issues/386/src/compact/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/compact/city.rs b/issues/386/src/compact/city.rs new file mode 100644 index 0000000000..02d28b0d14 --- /dev/null +++ b/issues/386/src/compact/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/compact/country.rs b/issues/386/src/compact/country.rs new file mode 100644 index 0000000000..9fe9682984 --- /dev/null +++ b/issues/386/src/compact/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/compact/customer.rs b/issues/386/src/compact/customer.rs new file mode 100644 index 0000000000..95807b652f --- /dev/null +++ b/issues/386/src/compact/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/compact/film.rs b/issues/386/src/compact/film.rs new file mode 100644 index 0000000000..39cf03306d --- /dev/null +++ b/issues/386/src/compact/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/compact/film_actor.rs b/issues/386/src/compact/film_actor.rs new file mode 100644 index 0000000000..ba23ccb774 --- /dev/null +++ b/issues/386/src/compact/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/compact/film_category.rs b/issues/386/src/compact/film_category.rs new file mode 100644 index 0000000000..222a773aad --- /dev/null +++ b/issues/386/src/compact/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/compact/film_text.rs b/issues/386/src/compact/film_text.rs new file mode 100644 index 0000000000..d8f26b6964 --- /dev/null +++ b/issues/386/src/compact/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/compact/inventory.rs b/issues/386/src/compact/inventory.rs new file mode 100644 index 0000000000..2f71f5c40f --- /dev/null +++ b/issues/386/src/compact/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/compact/language.rs b/issues/386/src/compact/language.rs new file mode 100644 index 0000000000..d77db36859 --- /dev/null +++ b/issues/386/src/compact/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/compact/mod.rs b/issues/386/src/compact/mod.rs new file mode 100644 index 0000000000..d7f098fca3 --- /dev/null +++ b/issues/386/src/compact/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/compact/payment.rs b/issues/386/src/compact/payment.rs new file mode 100644 index 0000000000..43c494b4a9 --- /dev/null +++ b/issues/386/src/compact/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/compact/prelude.rs b/issues/386/src/compact/prelude.rs new file mode 100644 index 0000000000..85cecd8718 --- /dev/null +++ b/issues/386/src/compact/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/compact/rental.rs b/issues/386/src/compact/rental.rs new file mode 100644 index 0000000000..15c7e9d907 --- /dev/null +++ b/issues/386/src/compact/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/compact/staff.rs b/issues/386/src/compact/staff.rs new file mode 100644 index 0000000000..805e5a26fa --- /dev/null +++ b/issues/386/src/compact/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/compact/store.rs b/issues/386/src/compact/store.rs new file mode 100644 index 0000000000..f7e1eb4a47 --- /dev/null +++ b/issues/386/src/compact/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 {} diff --git a/issues/386/src/expanded/actor.rs b/issues/386/src/expanded/actor.rs new file mode 100644 index 0000000000..578d11b209 --- /dev/null +++ b/issues/386/src/expanded/actor.rs @@ -0,0 +1,73 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "actor" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub actor_id: i32, + pub first_name: String, + pub last_name: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + ActorId, + FirstName, + LastName, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + ActorId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + true + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + FilmActor, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::ActorId => ColumnType::Integer.def(), + Self::FirstName => ColumnType::String(None).def(), + Self::LastName => ColumnType::String(None).def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::FilmActor => Entity::has_many(super::film_actor::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::FilmActor.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/expanded/address.rs b/issues/386/src/expanded/address.rs new file mode 100644 index 0000000000..e8b9a5b8cd --- /dev/null +++ b/issues/386/src/expanded/address.rs @@ -0,0 +1,112 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "address" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + 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, DeriveColumn)] +pub enum Column { + AddressId, + Address, + Address2, + District, + CityId, + PostalCode, + Phone, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + AddressId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + City, + Customer, + Staff, + Store, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::AddressId => ColumnType::Integer.def(), + Self::Address => ColumnType::String(None).def(), + Self::Address2 => ColumnType::String(None).def().null(), + Self::District => ColumnType::String(None).def(), + Self::CityId => ColumnType::Integer.def(), + Self::PostalCode => ColumnType::String(None).def().null(), + Self::Phone => ColumnType::String(None).def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::City => Entity::belongs_to(super::city::Entity) + .from(Column::CityId) + .to(super::city::Column::CityId) + .into(), + Self::Customer => Entity::has_many(super::customer::Entity).into(), + Self::Staff => Entity::has_many(super::staff::Entity).into(), + Self::Store => Entity::has_many(super::store::Entity).into(), + } + } +} + +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/expanded/category.rs b/issues/386/src/expanded/category.rs new file mode 100644 index 0000000000..4ce53b6a5a --- /dev/null +++ b/issues/386/src/expanded/category.rs @@ -0,0 +1,70 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "category" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub category_id: String, + pub name: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + CategoryId, + Name, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + CategoryId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + FilmCategory, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::CategoryId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::Name => ColumnType::String(None).def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::FilmCategory => Entity::has_many(super::film_category::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::FilmCategory.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/expanded/city.rs b/issues/386/src/expanded/city.rs new file mode 100644 index 0000000000..eb4010d208 --- /dev/null +++ b/issues/386/src/expanded/city.rs @@ -0,0 +1,84 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "city" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub city_id: i32, + pub city: String, + pub country_id: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + CityId, + City, + CountryId, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + CityId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Country, + Address, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::CityId => ColumnType::Integer.def(), + Self::City => ColumnType::String(None).def(), + Self::CountryId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Country => Entity::belongs_to(super::country::Entity) + .from(Column::CountryId) + .to(super::country::Column::CountryId) + .into(), + Self::Address => Entity::has_many(super::address::Entity).into(), + } + } +} + +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/expanded/country.rs b/issues/386/src/expanded/country.rs new file mode 100644 index 0000000000..5901ccbcab --- /dev/null +++ b/issues/386/src/expanded/country.rs @@ -0,0 +1,70 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "country" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub country_id: String, + pub country: String, + pub last_update: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + CountryId, + Country, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + CountryId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + City, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::CountryId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::Country => ColumnType::String(None).def(), + Self::LastUpdate => ColumnType::Timestamp.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::City => Entity::has_many(super::city::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::City.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/expanded/customer.rs b/issues/386/src/expanded/customer.rs new file mode 100644 index 0000000000..1adbaa6640 --- /dev/null +++ b/issues/386/src/expanded/customer.rs @@ -0,0 +1,118 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "customer" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub customer_id: i32, + pub store_id: i32, + pub first_name: String, + pub last_name: String, + pub email: Option, + pub address_id: i32, + pub active: String, + pub create_date: DateTime, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + CustomerId, + StoreId, + FirstName, + LastName, + Email, + AddressId, + Active, + CreateDate, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + CustomerId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Address, + Store, + Payment, + Rental, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::CustomerId => ColumnType::Integer.def(), + Self::StoreId => ColumnType::Integer.def(), + Self::FirstName => ColumnType::String(None).def(), + Self::LastName => ColumnType::String(None).def(), + Self::Email => ColumnType::String(None).def().null(), + Self::AddressId => ColumnType::Integer.def(), + Self::Active => ColumnType::Custom("BLOB".to_owned()).def(), + Self::CreateDate => ColumnType::Timestamp.def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Address => Entity::belongs_to(super::address::Entity) + .from(Column::AddressId) + .to(super::address::Column::AddressId) + .into(), + Self::Store => Entity::belongs_to(super::store::Entity) + .from(Column::StoreId) + .to(super::store::Column::StoreId) + .into(), + Self::Payment => Entity::has_many(super::payment::Entity).into(), + Self::Rental => Entity::has_many(super::rental::Entity).into(), + } + } +} + +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/expanded/film.rs b/issues/386/src/expanded/film.rs new file mode 100644 index 0000000000..b4e12ce33b --- /dev/null +++ b/issues/386/src/expanded/film.rs @@ -0,0 +1,126 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "film" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub film_id: i32, + pub title: String, + pub description: Option, + pub release_year: Option, + pub language_id: String, + pub original_language_id: Option, + pub rental_duration: String, + pub rental_rate: Decimal, + pub length: Option, + pub replacement_cost: Decimal, + pub rating: Option, + pub special_features: Option, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + FilmId, + Title, + Description, + ReleaseYear, + LanguageId, + OriginalLanguageId, + RentalDuration, + RentalRate, + Length, + ReplacementCost, + Rating, + SpecialFeatures, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + FilmId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Language2, + Language1, + FilmActor, + FilmCategory, + Inventory, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::FilmId => ColumnType::Integer.def(), + Self::Title => ColumnType::String(None).def(), + Self::Description => ColumnType::Custom("BLOB".to_owned()).def().null(), + Self::ReleaseYear => ColumnType::String(None).def().null(), + Self::LanguageId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::OriginalLanguageId => ColumnType::Custom("BLOB".to_owned()).def().null(), + Self::RentalDuration => ColumnType::Custom("BLOB".to_owned()).def(), + Self::RentalRate => ColumnType::Decimal(Some((4u32, 2u32))).def(), + Self::Length => ColumnType::Custom("BLOB".to_owned()).def().null(), + Self::ReplacementCost => ColumnType::Decimal(Some((5u32, 2u32))).def(), + Self::Rating => ColumnType::String(None).def().null(), + Self::SpecialFeatures => ColumnType::String(None).def().null(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Language2 => Entity::belongs_to(super::language::Entity) + .from(Column::OriginalLanguageId) + .to(super::language::Column::LanguageId) + .into(), + Self::Language1 => Entity::belongs_to(super::language::Entity) + .from(Column::LanguageId) + .to(super::language::Column::LanguageId) + .into(), + Self::FilmActor => Entity::has_many(super::film_actor::Entity).into(), + Self::FilmCategory => Entity::has_many(super::film_category::Entity).into(), + Self::Inventory => Entity::has_many(super::inventory::Entity).into(), + } + } +} + +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/expanded/film_actor.rs b/issues/386/src/expanded/film_actor.rs new file mode 100644 index 0000000000..86211cec0e --- /dev/null +++ b/issues/386/src/expanded/film_actor.rs @@ -0,0 +1,85 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "film_actor" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub actor_id: i32, + pub film_id: i32, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + ActorId, + FilmId, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + ActorId, + FilmId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (i32, i32); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Film, + Actor, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::ActorId => ColumnType::Integer.def(), + Self::FilmId => ColumnType::Integer.def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Film => Entity::belongs_to(super::film::Entity) + .from(Column::FilmId) + .to(super::film::Column::FilmId) + .into(), + Self::Actor => Entity::belongs_to(super::actor::Entity) + .from(Column::ActorId) + .to(super::actor::Column::ActorId) + .into(), + } + } +} + +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/expanded/film_category.rs b/issues/386/src/expanded/film_category.rs new file mode 100644 index 0000000000..c1cc118af1 --- /dev/null +++ b/issues/386/src/expanded/film_category.rs @@ -0,0 +1,85 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "film_category" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub film_id: i32, + pub category_id: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + FilmId, + CategoryId, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + FilmId, + CategoryId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (i32, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Category, + Film, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::FilmId => ColumnType::Integer.def(), + Self::CategoryId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Category => Entity::belongs_to(super::category::Entity) + .from(Column::CategoryId) + .to(super::category::Column::CategoryId) + .into(), + Self::Film => Entity::belongs_to(super::film::Entity) + .from(Column::FilmId) + .to(super::film::Column::FilmId) + .into(), + } + } +} + +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/expanded/film_text.rs b/issues/386/src/expanded/film_text.rs new file mode 100644 index 0000000000..87dbeda46f --- /dev/null +++ b/issues/386/src/expanded/film_text.rs @@ -0,0 +1,60 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "film_text" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub film_id: String, + pub title: String, + pub description: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + FilmId, + Title, + Description, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + FilmId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::FilmId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::Title => ColumnType::String(None).def(), + Self::Description => ColumnType::Custom("BLOB".to_owned()).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/expanded/inventory.rs b/issues/386/src/expanded/inventory.rs new file mode 100644 index 0000000000..dbbb412b43 --- /dev/null +++ b/issues/386/src/expanded/inventory.rs @@ -0,0 +1,95 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "inventory" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub inventory_id: i32, + pub film_id: i32, + pub store_id: i32, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + InventoryId, + FilmId, + StoreId, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + InventoryId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Film, + Store, + Rental, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::InventoryId => ColumnType::Integer.def(), + Self::FilmId => ColumnType::Integer.def(), + Self::StoreId => ColumnType::Integer.def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Film => Entity::belongs_to(super::film::Entity) + .from(Column::FilmId) + .to(super::film::Column::FilmId) + .into(), + Self::Store => Entity::belongs_to(super::store::Entity) + .from(Column::StoreId) + .to(super::store::Column::StoreId) + .into(), + Self::Rental => Entity::has_many(super::rental::Entity).into(), + } + } +} + +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/expanded/language.rs b/issues/386/src/expanded/language.rs new file mode 100644 index 0000000000..cffd118e01 --- /dev/null +++ b/issues/386/src/expanded/language.rs @@ -0,0 +1,60 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "language" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub language_id: String, + pub name: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + LanguageId, + Name, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + LanguageId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::LanguageId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::Name => ColumnType::Custom("BLOB".to_owned()).def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/issues/386/src/expanded/mod.rs b/issues/386/src/expanded/mod.rs new file mode 100644 index 0000000000..d7f098fca3 --- /dev/null +++ b/issues/386/src/expanded/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/expanded/payment.rs b/issues/386/src/expanded/payment.rs new file mode 100644 index 0000000000..7977464bf6 --- /dev/null +++ b/issues/386/src/expanded/payment.rs @@ -0,0 +1,107 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "payment" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub payment_id: i32, + pub customer_id: i32, + pub staff_id: String, + pub rental_id: Option, + pub amount: Decimal, + pub payment_date: DateTime, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + PaymentId, + CustomerId, + StaffId, + RentalId, + Amount, + PaymentDate, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + PaymentId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Staff, + Customer, + Rental, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::PaymentId => ColumnType::Integer.def(), + Self::CustomerId => ColumnType::Integer.def(), + Self::StaffId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::RentalId => ColumnType::Integer.def().null(), + Self::Amount => ColumnType::Decimal(Some((5u32, 2u32))).def(), + Self::PaymentDate => ColumnType::Timestamp.def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Staff => Entity::belongs_to(super::staff::Entity) + .from(Column::StaffId) + .to(super::staff::Column::StaffId) + .into(), + Self::Customer => Entity::belongs_to(super::customer::Entity) + .from(Column::CustomerId) + .to(super::customer::Column::CustomerId) + .into(), + Self::Rental => Entity::belongs_to(super::rental::Entity) + .from(Column::RentalId) + .to(super::rental::Column::RentalId) + .into(), + } + } +} + +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/expanded/prelude.rs b/issues/386/src/expanded/prelude.rs new file mode 100644 index 0000000000..85cecd8718 --- /dev/null +++ b/issues/386/src/expanded/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/expanded/rental.rs b/issues/386/src/expanded/rental.rs new file mode 100644 index 0000000000..952a0285a4 --- /dev/null +++ b/issues/386/src/expanded/rental.rs @@ -0,0 +1,115 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "rental" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub rental_id: i32, + pub rental_date: DateTime, + pub inventory_id: i32, + pub customer_id: i32, + pub return_date: Option, + pub staff_id: String, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + RentalId, + RentalDate, + InventoryId, + CustomerId, + ReturnDate, + StaffId, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + RentalId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Customer, + Inventory, + Staff, + Payment, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::RentalId => ColumnType::Integer.def(), + Self::RentalDate => ColumnType::Timestamp.def(), + Self::InventoryId => ColumnType::Integer.def(), + Self::CustomerId => ColumnType::Integer.def(), + Self::ReturnDate => ColumnType::Timestamp.def().null(), + Self::StaffId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Customer => Entity::belongs_to(super::customer::Entity) + .from(Column::CustomerId) + .to(super::customer::Column::CustomerId) + .into(), + Self::Inventory => Entity::belongs_to(super::inventory::Entity) + .from(Column::InventoryId) + .to(super::inventory::Column::InventoryId) + .into(), + Self::Staff => Entity::belongs_to(super::staff::Entity) + .from(Column::StaffId) + .to(super::staff::Column::StaffId) + .into(), + Self::Payment => Entity::has_many(super::payment::Entity).into(), + } + } +} + +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/expanded/staff.rs b/issues/386/src/expanded/staff.rs new file mode 100644 index 0000000000..a24721cf40 --- /dev/null +++ b/issues/386/src/expanded/staff.rs @@ -0,0 +1,124 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "staff" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub staff_id: String, + pub first_name: String, + pub last_name: String, + pub address_id: i32, + pub picture: Option, + pub email: Option, + pub store_id: i32, + pub active: String, + pub username: String, + pub password: Option, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + StaffId, + FirstName, + LastName, + AddressId, + Picture, + Email, + StoreId, + Active, + Username, + Password, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + StaffId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Address, + Store, + Payment, + Rental, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::StaffId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::FirstName => ColumnType::String(None).def(), + Self::LastName => ColumnType::String(None).def(), + Self::AddressId => ColumnType::Integer.def(), + Self::Picture => ColumnType::Custom("BLOB".to_owned()).def().null(), + Self::Email => ColumnType::String(None).def().null(), + Self::StoreId => ColumnType::Integer.def(), + Self::Active => ColumnType::Custom("BLOB".to_owned()).def(), + Self::Username => ColumnType::String(None).def(), + Self::Password => ColumnType::String(None).def().null(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Address => Entity::belongs_to(super::address::Entity) + .from(Column::AddressId) + .to(super::address::Column::AddressId) + .into(), + Self::Store => Entity::belongs_to(super::store::Entity) + .from(Column::StoreId) + .to(super::store::Column::StoreId) + .into(), + Self::Payment => Entity::has_many(super::payment::Entity).into(), + Self::Rental => Entity::has_many(super::rental::Entity).into(), + } + } +} + +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/expanded/store.rs b/issues/386/src/expanded/store.rs new file mode 100644 index 0000000000..1d04fd6665 --- /dev/null +++ b/issues/386/src/expanded/store.rs @@ -0,0 +1,103 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "store" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub store_id: i32, + pub manager_staff_id: String, + pub address_id: i32, + pub last_update: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + StoreId, + ManagerStaffId, + AddressId, + LastUpdate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + StoreId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Address, + Staff, + Customer, + Inventory, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::StoreId => ColumnType::Integer.def(), + Self::ManagerStaffId => ColumnType::Custom("BLOB".to_owned()).def(), + Self::AddressId => ColumnType::Integer.def(), + Self::LastUpdate => ColumnType::Timestamp.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Address => Entity::belongs_to(super::address::Entity) + .from(Column::AddressId) + .to(super::address::Column::AddressId) + .into(), + Self::Staff => Entity::belongs_to(super::staff::Entity) + .from(Column::ManagerStaffId) + .to(super::staff::Column::StaffId) + .into(), + Self::Customer => Entity::has_many(super::customer::Entity).into(), + Self::Inventory => Entity::has_many(super::inventory::Entity).into(), + } + } +} + +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 {} diff --git a/issues/386/src/main.rs b/issues/386/src/main.rs new file mode 100644 index 0000000000..c76f4650af --- /dev/null +++ b/issues/386/src/main.rs @@ -0,0 +1,4 @@ +mod compact; +mod expanded; + +pub fn main() {}