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 17 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
16 changes: 8 additions & 8 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.2'
- 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.2'
- 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.2'
- 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.2'
- 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 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-rc.2", default-features = false, 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-rc.2", 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,
}
10 changes: 8 additions & 2 deletions examples/mysql/src/entities/country.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! `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 = "country")]
pub struct Model {
#[sea_orm(primary_key)]
pub country_id: i32,
pub country_id: u16,
pub country: String,
pub last_update: DateTimeUtc,
}
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,
}
22 changes: 17 additions & 5 deletions examples/mysql/src/entities/customer.rs
Original file line number Diff line number Diff line change
@@ -1,20 +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 = "customer")]
pub struct Model {
#[sea_orm(primary_key)]
pub customer_id: i32,
pub store_id: i32,
pub customer_id: u16,
pub store_id: u8,
pub first_name: String,
pub last_name: String,
pub email: Option<String>,
pub address_id: i32,
pub address_id: u16,
pub active: i8,
pub create_date: DateTime,
pub last_update: DateTimeUtc,
pub last_update: Option<DateTimeUtc>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
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,
}
Loading