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

Slim query root #131

Merged
merged 20 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ categories = ["database"]

[dependencies]
async-graphql = { version = "5.0.6", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
sea-orm = { version = "0.11.0", default-features = false }
sea-orm = { version = "0.12.0", default-features = false, git = "https://github.com/karatakis/sea-orm.git", branch = "seaography-generator" }
itertools = { version = "0.10.5" }
heck = { version = "0.4.1" }

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Setup the [sakila](https://github.com/SeaQL/seaography/blob/main/examples/mysql/

```sh
cd examples/mysql
sea-orm-cli generate entity -o src/entities -u mysql://user:[email protected]/sakila
sea-orm-cli generate entity -o src/entities -u mysql://user:[email protected]/sakila -seaography
seaography-cli ./ src/entities mysql://user:[email protected]/sakila seaography-mysql-example
cargo run
```
Expand Down Expand Up @@ -205,7 +205,7 @@ Setup the [sakila](https://github.com/SeaQL/seaography/blob/main/examples/postgr

```sh
cd examples/postgres
sea-orm-cli generate entity -o src/entities -u postgres://user:pw@localhost/sakila
sea-orm-cli generate entity -o src/entities -u postgres://user:pw@localhost/sakila -seaography
seaography-cli ./ src/entities postgres://user:pw@localhost/sakila seaography-postgres-example
cargo run
```
Expand All @@ -214,7 +214,7 @@ cargo run

```sh
cd examples/sqlite
sea-orm-cli generate entity -o src/entities -u sqlite://sakila.db
sea-orm-cli generate entity -o src/entities -u sqlite://sakila.db -seaography
seaography-cli ./ src/entities sqlite://sakila.db seaography-sqlite-example
cargo run
```
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async-graphql-poem = { version = "5.0.6" }
async-graphql = { version = "5.0.6", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
async-trait = { version = "0.1.64" }
dotenv = "0.15.0"
sea-orm = { version = "0.11.0", features = ["sqlx-mysql", "runtime-async-std-native-tls"] }
sea-orm = { version = "0.12.0", git = "https://github.com/karatakis/sea-orm.git", branch = "seaography-generator", features = ["sqlx-mysql", "runtime-async-std-native-tls"] }
tokio = { version = "1.26.0", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1.37" }
tracing-subscriber = { version = "0.3.16" }
Expand Down
2 changes: 1 addition & 1 deletion examples/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async-graphql-poem = { version = "5.0.6" }
async-graphql = { version = "5.0.6", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
async-trait = { version = "0.1.64" }
dotenv = "0.15.0"
sea-orm = { version = "0.11.0", features = ["sqlx-postgres", "runtime-async-std-native-tls"] }
sea-orm = { version = "0.12.0", git = "https://github.com/karatakis/sea-orm.git", branch = "seaography-generator", features = ["sqlx-postgres", "runtime-async-std-native-tls"] }
tokio = { version = "1.26.0", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1.37" }
tracing-subscriber = { version = "0.3.16" }
Expand Down
2 changes: 1 addition & 1 deletion examples/sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async-graphql-poem = { version = "5.0.6" }
async-graphql = { version = "5.0.6", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
async-trait = { version = "0.1.64" }
dotenv = "0.15.0"
sea-orm = { version = "0.11.0", features = ["sqlx-sqlite", "runtime-async-std-native-tls"] }
sea-orm = { version = "0.12.0", git = "https://github.com/karatakis/sea-orm.git", branch = "seaography-generator", features = ["sqlx-sqlite", "runtime-async-std-native-tls"] }
tokio = { version = "1.26.0", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1.37" }
tracing-subscriber = { version = "0.3.16" }
Expand Down
21 changes: 19 additions & 2 deletions examples/sqlite/src/entities/actor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand All @@ -13,7 +13,16 @@ pub struct Model {
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
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 Related<super::film::Entity> for Entity {
fn to() -> RelationDef {
Expand All @@ -25,3 +34,11 @@ impl Related<super::film::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::film_actor::Entity")]
FilmActor,
#[sea_orm(entity = "super::film::Entity")]
Film,
}
14 changes: 13 additions & 1 deletion examples/sqlite/src/entities/address.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand Down Expand Up @@ -59,3 +59,15 @@ impl Related<super::store::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::city::Entity")]
City,
#[sea_orm(entity = "super::customer::Entity")]
Customer,
#[sea_orm(entity = "super::staff::Entity")]
Staff,
#[sea_orm(entity = "super::store::Entity")]
Store,
}
21 changes: 19 additions & 2 deletions examples/sqlite/src/entities/category.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand All @@ -12,7 +12,16 @@ pub struct Model {
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
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 Related<super::film::Entity> for Entity {
fn to() -> RelationDef {
Expand All @@ -24,3 +33,11 @@ impl Related<super::film::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::film_category::Entity")]
FilmCategory,
#[sea_orm(entity = "super::film::Entity")]
Film,
}
10 changes: 9 additions & 1 deletion examples/sqlite/src/entities/city.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand Down Expand Up @@ -39,3 +39,11 @@ impl Related<super::country::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::address::Entity")]
Address,
#[sea_orm(entity = "super::country::Entity")]
Country,
}
8 changes: 7 additions & 1 deletion examples/sqlite/src/entities/country.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand All @@ -24,3 +24,9 @@ impl Related<super::city::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::city::Entity")]
City,
}
14 changes: 13 additions & 1 deletion examples/sqlite/src/entities/customer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand Down Expand Up @@ -66,3 +66,15 @@ impl Related<super::store::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::address::Entity")]
Address,
#[sea_orm(entity = "super::payment::Entity")]
Payment,
#[sea_orm(entity = "super::rental::Entity")]
Rental,
#[sea_orm(entity = "super::store::Entity")]
Store,
}
36 changes: 35 additions & 1 deletion examples/sqlite/src/entities/film.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand All @@ -25,6 +25,10 @@ pub struct Model {

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[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,
#[sea_orm(
Expand All @@ -45,6 +49,18 @@ pub enum Relation {
Language1,
}

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()
Expand All @@ -70,3 +86,21 @@ impl Related<super::category::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::film_actor::Entity")]
FilmActor,
#[sea_orm(entity = "super::film_category::Entity")]
FilmCategory,
#[sea_orm(entity = "super::inventory::Entity")]
Inventory,
#[sea_orm(entity = "super::language::Entity", def = "Relation::Language2.def()")]
Language2,
#[sea_orm(entity = "super::language::Entity", def = "Relation::Language1.def()")]
Language1,
#[sea_orm(entity = "super::actor::Entity")]
Actor,
#[sea_orm(entity = "super::category::Entity")]
Category,
}
10 changes: 9 additions & 1 deletion examples/sqlite/src/entities/film_actor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand Down Expand Up @@ -45,3 +45,11 @@ impl Related<super::film::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::actor::Entity")]
Actor,
#[sea_orm(entity = "super::film::Entity")]
Film,
}
10 changes: 9 additions & 1 deletion examples/sqlite/src/entities/film_category.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand Down Expand Up @@ -45,3 +45,11 @@ impl Related<super::film::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::category::Entity")]
Category,
#[sea_orm(entity = "super::film::Entity")]
Film,
}
5 changes: 4 additions & 1 deletion examples/sqlite/src/entities/film_text.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand All @@ -15,3 +15,6 @@ pub struct Model {
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {}
12 changes: 11 additions & 1 deletion examples/sqlite/src/entities/inventory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand Down Expand Up @@ -53,3 +53,13 @@ impl Related<super::store::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::film::Entity")]
Film,
#[sea_orm(entity = "super::rental::Entity")]
Rental,
#[sea_orm(entity = "super::store::Entity")]
Store,
}
6 changes: 5 additions & 1 deletion examples/sqlite/src/entities/language.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand All @@ -7,6 +7,7 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub language_id: i16,
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
pub name: Vec<u8>,
pub last_update: DateTimeUtc,
}
Expand All @@ -15,3 +16,6 @@ pub struct Model {
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {}
2 changes: 1 addition & 1 deletion examples/sqlite/src/entities/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

pub mod prelude;

Expand Down
12 changes: 11 additions & 1 deletion examples/sqlite/src/entities/payment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

use sea_orm::entity::prelude::*;

Expand Down Expand Up @@ -63,3 +63,13 @@ impl Related<super::staff::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
pub enum RelatedEntity {
#[sea_orm(entity = "super::customer::Entity")]
Customer,
#[sea_orm(entity = "super::rental::Entity")]
Rental,
#[sea_orm(entity = "super::staff::Entity")]
Staff,
}
2 changes: 1 addition & 1 deletion examples/sqlite/src/entities/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0

pub use super::actor::Entity as Actor;
pub use super::address::Entity as Address;
Expand Down
Loading