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 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
18 changes: 9 additions & 9 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ jobs:
uses: baptiste0928/cargo-install@v2
with:
crate: sea-orm-cli
version: '0.11.0'
version: '0.12.0-rc.5'
- name: Remove generated folder
run: rm -rf ./examples/sqlite/src
- name: Copy sample database
run: cp ./examples/sqlite/sakila.db .
- name: Generate entities
run: sea-orm-cli generate entity -o examples/sqlite/src/entities -u sqlite://sakila.db
run: sea-orm-cli generate entity -o examples/sqlite/src/entities -u sqlite://sakila.db --seaography
- name: Generate Seaography project
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -135,13 +135,13 @@ jobs:
uses: baptiste0928/cargo-install@v2
with:
crate: sea-orm-cli
version: '0.11.0'
version: '0.12.0-rc.5'
- name: Remove generated folder
run: rm -rf ./examples/sqlite/src
- name: Copy sample database
run: cp ./examples/sqlite/sakila.db .
- name: Generate entities
run: sea-orm-cli generate entity -o examples/sqlite/src/entities -u sqlite://sakila.db
run: sea-orm-cli generate entity -o examples/sqlite/src/entities -u sqlite://sakila.db --seaography
- name: Generate Seaography project
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
uses: baptiste0928/cargo-install@v2
with:
crate: sea-orm-cli
version: '0.11.0'
version: '0.12.0-rc.5'
- name: Remove generated folder
run: rm -rf ./examples/mysql/src
- name: Create DB
Expand All @@ -204,7 +204,7 @@ jobs:
run: mysql -uroot -h 127.0.0.1 sakila < sakila-data.sql
working-directory: ./examples/mysql
- name: Generate entities
run: sea-orm-cli generate entity -o ./examples/mysql/src/entities -u mysql://sea:[email protected]/sakila
run: sea-orm-cli generate entity -o ./examples/mysql/src/entities -u mysql://sea:[email protected]/sakila --seaography
- name: Generate Seaography project
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
uses: baptiste0928/cargo-install@v2
with:
crate: sea-orm-cli
version: '0.11.0'
version: '0.12.0-rc.5'
- name: Remove generated folder
run: rm -rf ./examples/postgres/src
- name: Create DB
Expand All @@ -264,7 +264,7 @@ jobs:
run: psql -q postgres://sea:sea@localhost/sakila < sakila-data.sql
working-directory: ./examples/postgres
- name: Generate entities
run: sea-orm-cli generate entity -o ./examples/postgres/src/entities -u postgres://sea:[email protected]/sakila?currentSchema=public
run: sea-orm-cli generate entity -o ./examples/postgres/src/entities -u postgres://sea:[email protected]/sakila?currentSchema=public --seaography
- name: Generate Seaography project
uses: actions-rs/cargo@v1
with:
Expand All @@ -275,7 +275,7 @@ jobs:
- name: Depends on local seaography
run: sed -i '/^\[dependencies.seaography\]$/a \path = "..\/..\/"' ./examples/postgres/Cargo.toml
- name: Fix Nullable not implemented for Vec<String> and tsvector
run: sed -i "25,27d" ./examples/postgres/src/entities/film.rs
run: sed -i "26,27d" ./examples/postgres/src/entities/film.rs
- name: Build example
working-directory: ./examples/postgres
run: cargo build
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ keywords = ["async", "graphql", "mysql", "postgres", "sqlite"]
categories = ["database"]

[dependencies]
async-graphql = { version = "5.0.6", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
sea-orm = { version = "0.11.0", default-features = false }
itertools = { version = "0.10.5" }
async-graphql = { version = "5.0.10", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
sea-orm = { version = "0.12.0-rc.5", default-features = false, features = ["seaography"] }
itertools = { version = "0.11.0" }
heck = { version = "0.4.1" }

[features]
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
4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ categories = ["database"]

[dependencies]
async-std = { version = "1.12.0", features = [ "attributes", "tokio1" ] }
clap = { version = "4.2.1", features = ["derive"] }
clap = { version = "4.3.19", features = ["derive"] }
seaography-generator = { version = "^1.0.0", path = "../generator" }
url = "2.3.1"
url = "2.4.0"
18 changes: 9 additions & 9 deletions examples/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ name = "seaography-mysql-example"
version = "0.3.0"

[dependencies]
poem = { version = "1.3.55" }
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" }
poem = { version = "1.3.56" }
async-graphql-poem = { version = "5.0.10" }
async-graphql = { version = "5.0.10", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
async-trait = { version = "0.1.72" }
dotenv = "0.15.0"
sea-orm = { version = "0.11.0", features = ["sqlx-mysql", "runtime-async-std-native-tls"] }
tokio = { version = "1.26.0", features = ["macros", "rt-multi-thread"] }
sea-orm = { version = "0.12.0-rc.5", features = ["sqlx-mysql", "runtime-async-std-native-tls", "seaography"] }
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1.37" }
tracing-subscriber = { version = "0.3.16" }
tracing-subscriber = { version = "0.3.17" }
lazy_static = { version = "1.4.0" }

[dependencies.seaography]
path = "../../" # remove this line in your own project
path = "../../"
version = "^1.0.0" # seaography version
features = ["with-decimal", "with-chrono"]

[dev-dependencies]
serde_json = { version = "1.0.82" }
serde_json = { version = "1.0.103" }

[workspace]
members = []
21 changes: 19 additions & 2 deletions examples/mysql/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-rc.5

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,
}
15 changes: 14 additions & 1 deletion examples/mysql/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-rc.5

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

Expand All @@ -13,6 +13,7 @@ pub struct Model {
pub city_id: i32,
pub postal_code: Option<String>,
pub phone: String,
#[sea_orm(column_type = "VarBinary(25)", nullable)]
pub location: Option<Vec<u8>>,
pub last_update: DateTimeUtc,
}
Expand Down Expand Up @@ -60,3 +61,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/mysql/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-rc.5

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/mysql/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-rc.5

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/mysql/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-rc.5

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/mysql/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-rc.5

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/mysql/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-rc.5

use super::sea_orm_active_enums::Rating;
use sea_orm::entity::prelude::*;
Expand Down Expand Up @@ -31,6 +31,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 @@ -51,6 +55,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 @@ -76,3 +92,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/mysql/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-rc.5

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,
}
Loading