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 13 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
148 changes: 74 additions & 74 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,26 @@ jobs:
profile: minimal
toolchain: stable
override: true
- name: Install sea-orm-cli
uses: baptiste0928/cargo-install@v2
with:
crate: sea-orm-cli
version: '0.11.0'
- name: Remove generated folder
run: rm -rf ./examples/sqlite/src
# - name: Install sea-orm-cli
# uses: baptiste0928/cargo-install@v2
# with:
# crate: sea-orm-cli
# version: '0.11.0'
# - 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
- name: Generate Seaography project
uses: actions-rs/cargo@v1
with:
command: run
args: >
--package seaography-cli --
./examples/sqlite ./examples/sqlite/src/entities sqlite://sakila.db seaography-sqlite-example -f poem
- name: Depends on local seaography
run: sed -i '/^\[dependencies.seaography\]$/a \path = "..\/..\/"' ./examples/sqlite/Cargo.toml
# - name: Generate entities
# run: sea-orm-cli generate entity -o examples/sqlite/src/entities -u sqlite://sakila.db
# - name: Generate Seaography project
# uses: actions-rs/cargo@v1
# with:
# command: run
# args: >
# --package seaography-cli --
# ./examples/sqlite ./examples/sqlite/src/entities sqlite://sakila.db seaography-sqlite-example -f poem
# - name: Depends on local seaography
# run: sed -i '/^\[dependencies.seaography\]$/a \path = "..\/..\/"' ./examples/sqlite/Cargo.toml
- name: Build example
working-directory: ./examples/sqlite
run: cargo build
Expand All @@ -131,26 +131,26 @@ jobs:
profile: minimal
toolchain: stable
override: true
- name: Install sea-orm-cli
uses: baptiste0928/cargo-install@v2
with:
crate: sea-orm-cli
version: '0.11.0'
- name: Remove generated folder
run: rm -rf ./examples/sqlite/src
# - name: Install sea-orm-cli
# uses: baptiste0928/cargo-install@v2
# with:
# crate: sea-orm-cli
# version: '0.11.0'
# - 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
- name: Generate Seaography project
uses: actions-rs/cargo@v1
with:
command: run
args: >
--package seaography-cli --
./examples/sqlite ./examples/sqlite/src/entities sqlite://sakila.db seaography-sqlite-example -f actix
- name: Depends on local seaography
run: sed -i '/^\[dependencies.seaography\]$/a \path = "..\/..\/"' ./examples/sqlite/Cargo.toml
# - name: Generate entities
# run: sea-orm-cli generate entity -o examples/sqlite/src/entities -u sqlite://sakila.db
# - name: Generate Seaography project
# uses: actions-rs/cargo@v1
# with:
# command: run
# args: >
# --package seaography-cli --
# ./examples/sqlite ./examples/sqlite/src/entities sqlite://sakila.db seaography-sqlite-example -f actix
# - name: Depends on local seaography
# run: sed -i '/^\[dependencies.seaography\]$/a \path = "..\/..\/"' ./examples/sqlite/Cargo.toml
- name: Build example
working-directory: ./examples/sqlite
run: cargo build
Expand Down Expand Up @@ -186,13 +186,13 @@ jobs:
profile: minimal
toolchain: stable
override: true
- name: Install sea-orm-cli
uses: baptiste0928/cargo-install@v2
with:
crate: sea-orm-cli
version: '0.11.0'
- name: Remove generated folder
run: rm -rf ./examples/mysql/src
# - name: Install sea-orm-cli
# uses: baptiste0928/cargo-install@v2
# with:
# crate: sea-orm-cli
# version: '0.11.0'
# - name: Remove generated folder
# run: rm -rf ./examples/mysql/src
- name: Create DB
run: mysql -uroot -h 127.0.0.1 mysql -e 'CREATE DATABASE `sakila`'
- name: Grant Privilege
Expand All @@ -203,17 +203,17 @@ jobs:
- name: Import DB Data
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
- name: Generate Seaography project
uses: actions-rs/cargo@v1
with:
command: run
args: >
--package seaography-cli --
./examples/mysql ./examples/mysql/src/entities mysql://sea:[email protected]/sakila seaography-mysql-example
- name: Depends on local seaography
run: sed -i '/^\[dependencies.seaography\]$/a \path = "..\/..\/"' ./examples/mysql/Cargo.toml
# - name: Generate entities
# run: sea-orm-cli generate entity -o ./examples/mysql/src/entities -u mysql://sea:[email protected]/sakila
# - name: Generate Seaography project
# uses: actions-rs/cargo@v1
# with:
# command: run
# args: >
# --package seaography-cli --
# ./examples/mysql ./examples/mysql/src/entities mysql://sea:[email protected]/sakila seaography-mysql-example
# - name: Depends on local seaography
# run: sed -i '/^\[dependencies.seaography\]$/a \path = "..\/..\/"' ./examples/mysql/Cargo.toml
- name: Build example
working-directory: ./examples/mysql
run: cargo build
Expand Down Expand Up @@ -248,13 +248,13 @@ jobs:
profile: minimal
toolchain: stable
override: true
- name: Install sea-orm-cli
uses: baptiste0928/cargo-install@v2
with:
crate: sea-orm-cli
version: '0.11.0'
- name: Remove generated folder
run: rm -rf ./examples/postgres/src
# - name: Install sea-orm-cli
# uses: baptiste0928/cargo-install@v2
# with:
# crate: sea-orm-cli
# version: '0.11.0'
# - name: Remove generated folder
# run: rm -rf ./examples/postgres/src
- name: Create DB
run: psql -q postgres://sea:sea@localhost/postgres -c 'CREATE DATABASE "sakila"'
- name: Import DB Schema
Expand All @@ -263,19 +263,19 @@ jobs:
- name: Import DB Data
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
- name: Generate Seaography project
uses: actions-rs/cargo@v1
with:
command: run
args: >
--package seaography-cli --
./examples/postgres ./examples/postgres/src/entities postgres://sea:[email protected]/sakila?currentSchema=public seaography-postgres-example
- 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
# - name: Generate entities
# run: sea-orm-cli generate entity -o ./examples/postgres/src/entities -u postgres://sea:[email protected]/sakila?currentSchema=public
# - name: Generate Seaography project
# uses: actions-rs/cargo@v1
# with:
# command: run
# args: >
# --package seaography-cli --
# ./examples/postgres ./examples/postgres/src/entities postgres://sea:[email protected]/sakila?currentSchema=public seaography-postgres-example
# - 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
- name: Build example
working-directory: ./examples/postgres
run: cargo build
Expand Down
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", features = ["seaography"] }
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", "seaography"] }
tokio = { version = "1.26.0", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1.37" }
tracing-subscriber = { version = "0.3.16" }
Expand Down
23 changes: 20 additions & 3 deletions examples/mysql/src/entities/actor.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
//! `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::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "actor")]
pub struct Model {
#[sea_orm(primary_key)]
pub actor_id: i32,
pub actor_id: u16,
pub first_name: String,
pub last_name: String,
pub last_update: DateTimeUtc,
}

#[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,
}
21 changes: 17 additions & 4 deletions examples/mysql/src/entities/address.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
//! `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::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "address")]
pub struct Model {
#[sea_orm(primary_key)]
pub address_id: i32,
pub address_id: u16,
pub address: String,
pub address2: Option<String>,
pub district: String,
pub city_id: i32,
pub city_id: u16,
pub postal_code: Option<String>,
pub phone: String,
pub location: Option<Vec<u8>>,
#[sea_orm(column_type = "custom(\"GEOMETRY\")")]
pub location: String,
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

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,
}
14 changes: 11 additions & 3 deletions examples/mysql/src/entities/city.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! `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::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "city")]
pub struct Model {
#[sea_orm(primary_key)]
pub city_id: i32,
pub city_id: u16,
pub city: String,
pub country_id: i32,
pub country_id: u16,
pub last_update: DateTimeUtc,
}

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