Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen SQLite #386

Merged
merged 4 commits into from
Dec 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions issues/386/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" ]}
27 changes: 27 additions & 0 deletions issues/386/src/compact/actor.rs
Original file line number Diff line number Diff line change
@@ -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<super::film_actor::Entity> for Entity {
fn to() -> RelationDef {
Relation::FilmActor.def()
}
}

impl ActiveModelBehavior for ActiveModel {}
61 changes: 61 additions & 0 deletions issues/386/src/compact/address.rs
Original file line number Diff line number Diff line change
@@ -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<String>,
pub district: String,
pub city_id: i32,
pub postal_code: Option<String>,
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<super::city::Entity> for Entity {
fn to() -> RelationDef {
Relation::City.def()
}
}

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

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

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

impl ActiveModelBehavior for ActiveModel {}
30 changes: 30 additions & 0 deletions issues/386/src/compact/category.rs
Original file line number Diff line number Diff line change
@@ -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<super::film_category::Entity> for Entity {
fn to() -> RelationDef {
Relation::FilmCategory.def()
}
}

impl ActiveModelBehavior for ActiveModel {}
42 changes: 42 additions & 0 deletions issues/386/src/compact/city.rs
Original file line number Diff line number Diff line change
@@ -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<super::country::Entity> for Entity {
fn to() -> RelationDef {
Relation::Country.def()
}
}

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

impl ActiveModelBehavior for ActiveModel {}
30 changes: 30 additions & 0 deletions issues/386/src/compact/country.rs
Original file line number Diff line number Diff line change
@@ -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<DateTime>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::city::Entity")]
City,
}

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

impl ActiveModelBehavior for ActiveModel {}
69 changes: 69 additions & 0 deletions issues/386/src/compact/customer.rs
Original file line number Diff line number Diff line change
@@ -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<String>,
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<super::address::Entity> for Entity {
fn to() -> RelationDef {
Relation::Address.def()
}
}

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

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

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

impl ActiveModelBehavior for ActiveModel {}
75 changes: 75 additions & 0 deletions issues/386/src/compact/film.rs
Original file line number Diff line number Diff line change
@@ -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<String>,
pub release_year: Option<String>,
#[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<String>,
#[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<String>,
#[sea_orm(column_type = "Decimal(Some((5, 2)))")]
pub replacement_cost: Decimal,
pub rating: Option<String>,
pub special_features: Option<String>,
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<super::film_actor::Entity> for Entity {
fn to() -> RelationDef {
Relation::FilmActor.def()
}
}

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

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

impl ActiveModelBehavior for ActiveModel {}
Loading