Skip to content

Commit

Permalink
Merge pull request #1881 from langyo/proxy-conn
Browse files Browse the repository at this point in the history
feat: Add proxy connection type
  • Loading branch information
tyt2y3 authored Nov 19, 2023
2 parents 8aa49be + de66032 commit 2844d03
Show file tree
Hide file tree
Showing 35 changed files with 2,466 additions and 45 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
# GitHub Actions with Conditional Job Running Based on Commit Message
#
#
# --------------------------------------------------------------------------------
#
#
# Following jobs will always run
#
#
# - `clippy`
# - `test`
# - `examples`
#
#
# Following jobs will be run when no keywords were found in commit message)
#
#
# - `compile-sqlite`
# - `sqlite`
# - `compile-mysql`
# - `mysql`
# - `mariadb`
# - `compile-postgres`
# - `postgres`
#
#
# Following jobs will be run if keywords `[issues]` were found in commit message
#
#
# - Jobs that will always run
# - `issues`
#
#
# Following jobs will be run if keywords `[cli]` were found in commit message
#
#
# - Jobs that will always run
# - `cli`
#
#
# Following jobs will be run if keywords `[sqlite]` were found in commit message
#
#
# - Jobs that will always run
# - `compile-sqlite`
# - `sqlite`
#
#
# Following jobs will be run if keywords `[mysql]` were found in commit message
#
#
# - Jobs that will always run
# - `compile-mysql`
# - `mysql`
# - `mariadb`
#
#
# Following jobs will be run if keywords `[postgres]` were found in commit message
#
#
# - Jobs that will always run
# - `compile-postgres`
# - `postgres`


name: tests

on:
Expand All @@ -73,7 +72,6 @@ env:
CARGO_TERM_COLOR: always

jobs:

init:
name: Init
runs-on: ubuntu-latest
Expand Down Expand Up @@ -252,8 +250,10 @@ jobs:
with:
toolchain: nightly
components: rustfmt
- run: rustup target add wasm32-wasi
- run: find ${{ matrix.path }} -type f -name 'Cargo.toml' -print0 | xargs -t -0 -I {} cargo fmt --manifest-path {} -- --check
- uses: dtolnay/rust-toolchain@stable
- run: rustup target add wasm32-wasi
- run: find ${{ matrix.path }} -type f -name 'Cargo.toml' -print0 | xargs -t -0 -I {} cargo build --manifest-path {}
- run: find ${{ matrix.path }} -type f -name 'Cargo.toml' -print0 | xargs -t -0 -I {} cargo test --manifest-path {}
- run: ${{'! '}}${{ '[ -d "' }}${{ matrix.path }}${{ '/service" ]' }} || find ${{ matrix.path }}/service -type f -name 'Cargo.toml' -print0 | xargs -t -0 -I {} cargo test --manifest-path {} --features mock
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
}}
runs-on: ubuntu-latest
env:
DATABASE_URL: "sqlite::memory:"
DATABASE_URL: 'sqlite::memory:'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -331,7 +331,7 @@ jobs:
}}
runs-on: ubuntu-latest
env:
DATABASE_URL: "mysql://root:@localhost"
DATABASE_URL: 'mysql://root:@localhost'
strategy:
fail-fast: false
matrix:
Expand All @@ -349,7 +349,7 @@ jobs:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD:
ports:
- "3306:3306"
- '3306:3306'
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
Expand Down Expand Up @@ -381,7 +381,7 @@ jobs:
}}
runs-on: ubuntu-latest
env:
DATABASE_URL: "mysql://root:@localhost"
DATABASE_URL: 'mysql://root:@localhost'
strategy:
fail-fast: false
matrix:
Expand All @@ -399,7 +399,7 @@ jobs:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD:
ports:
- "3306:3306"
- '3306:3306'
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
Expand Down Expand Up @@ -430,7 +430,7 @@ jobs:
}}
runs-on: ubuntu-latest
env:
DATABASE_URL: "postgres://root:root@localhost"
DATABASE_URL: 'postgres://root:root@localhost'
strategy:
fail-fast: false
matrix:
Expand All @@ -445,7 +445,7 @@ jobs:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
ports:
- "5432:5432"
- '5432:5432'
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down
93 changes: 80 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ keywords = ["async", "orm", "mysql", "postgres", "sqlite"]
rust-version = "1.65"

[package.metadata.docs.rs]
features = ["default", "sqlx-all", "mock", "runtime-async-std-native-tls", "postgres-array", "sea-orm-internal"]
features = [
"default",
"sqlx-all",
"mock",
"proxy",
"runtime-async-std-native-tls",
"postgres-array",
"sea-orm-internal",
]
rustdoc-args = ["--cfg", "docsrs"]

[lib]
Expand All @@ -30,7 +38,10 @@ chrono = { version = "0.4.30", default-features = false, optional = true }
time = { version = "0.3", default-features = false, optional = true }
futures = { version = "0.3", default-features = false, features = ["std"] }
log = { version = "0.4", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
tracing = { version = "0.1", default-features = false, features = [
"attributes",
"log",
] }
rust_decimal = { version = "1", default-features = false, optional = true }
bigdecimal = { version = "0.3", default-features = false, optional = true }
sea-orm-macros = { version = "0.12.6", path = "sea-orm-macros", default-features = false, features = ["strum"] }
Expand All @@ -39,12 +50,14 @@ sea-query-binder = { version = "0.5.0", default-features = false, optional = tru
strum = { version = "0.25", default-features = false }
serde = { version = "1.0", default-features = false }
serde_json = { version = "1.0", default-features = false, optional = true }
sqlx = { version = "0.7", default-features = false, optional = true }
uuid = { version = "1", default-features = false, optional = true }
ouroboros = { version = "0.17", default-features = false }
url = { version = "2.2", default-features = false }
thiserror = { version = "1", default-features = false }

[target.'cfg(not(wasm))'.dependencies]
sqlx = { version = "0.7", default-features = false, optional = true }

[dev-dependencies]
smol = { version = "1.2" }
smol-potat = { version = "1.1" }
Expand All @@ -55,7 +68,14 @@ actix-rt = { version = "2.2.0" }
maplit = { version = "1" }
rust_decimal_macros = { version = "1" }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
sea-orm = { path = ".", features = ["mock", "debug-print", "tests-cfg", "postgres-array", "sea-orm-internal"] }
sea-orm = { path = ".", features = [
"mock",
"proxy",
"debug-print",
"tests-cfg",
"postgres-array",
"sea-orm-internal",
] }
pretty_assertions = { version = "0.7" }
time = { version = "0.3", features = ["macros"] }
uuid = { version = "1", features = ["v4"] }
Expand All @@ -76,19 +96,66 @@ default = [
]
macros = ["sea-orm-macros/derive"]
mock = []
with-json = ["serde_json", "sea-query/with-json", "chrono?/serde", "time?/serde", "uuid?/serde", "sea-query-binder?/with-json", "sqlx?/json"]
with-chrono = ["chrono", "sea-query/with-chrono", "sea-query-binder?/with-chrono", "sqlx?/chrono"]
with-rust_decimal = ["rust_decimal", "sea-query/with-rust_decimal", "sea-query-binder?/with-rust_decimal", "sqlx?/rust_decimal"]
with-bigdecimal = ["bigdecimal", "sea-query/with-bigdecimal", "sea-query-binder?/with-bigdecimal", "sqlx?/bigdecimal"]
with-uuid = ["uuid", "sea-query/with-uuid", "sea-query-binder?/with-uuid", "sqlx?/uuid"]
with-time = ["time", "sea-query/with-time", "sea-query-binder?/with-time", "sqlx?/time"]
postgres-array = ["sea-query/postgres-array", "sea-query-binder?/postgres-array", "sea-orm-macros/postgres-array"]
json-array = ["postgres-array"] # this does not actually enable sqlx-postgres, but only a few traits to support array in sea-query
proxy = ["serde_json"]
with-json = [
"serde_json",
"sea-query/with-json",
"chrono?/serde",
"time?/serde",
"uuid?/serde",
"sea-query-binder?/with-json",
"sqlx?/json",
]
with-chrono = [
"chrono",
"sea-query/with-chrono",
"sea-query-binder?/with-chrono",
"sqlx?/chrono",
]
with-rust_decimal = [
"rust_decimal",
"sea-query/with-rust_decimal",
"sea-query-binder?/with-rust_decimal",
"sqlx?/rust_decimal",
]
with-bigdecimal = [
"bigdecimal",
"sea-query/with-bigdecimal",
"sea-query-binder?/with-bigdecimal",
"sqlx?/bigdecimal",
]
with-uuid = [
"uuid",
"sea-query/with-uuid",
"sea-query-binder?/with-uuid",
"sqlx?/uuid",
]
with-time = [
"time",
"sea-query/with-time",
"sea-query-binder?/with-time",
"sqlx?/time",
]
with-ipnetwork = ["sea-query/with-ipnetwork"]
with-mac_address = ["sea-query/with-mac_address"]
postgres-array = [
"sea-query/postgres-array",
"sea-query-binder?/postgres-array",
"sea-orm-macros/postgres-array",
]
json-array = [
"postgres-array",
] # this does not actually enable sqlx-postgres, but only a few traits to support array in sea-query
sea-orm-internal = []
sqlx-dep = []
sqlx-all = ["sqlx-mysql", "sqlx-postgres", "sqlx-sqlite"]
sqlx-mysql = ["sqlx-dep", "sea-query-binder/sqlx-mysql", "sqlx/mysql"]
sqlx-postgres = ["sqlx-dep", "sea-query-binder/sqlx-postgres", "sqlx/postgres", "postgres-array"]
sqlx-postgres = [
"sqlx-dep",
"sea-query-binder/sqlx-postgres",
"sqlx/postgres",
"postgres-array",
]
sqlx-sqlite = ["sqlx-dep", "sea-query-binder/sqlx-sqlite", "sqlx/sqlite"]
runtime-async-std = []
runtime-async-std-native-tls = [
Expand Down
33 changes: 33 additions & 0 deletions examples/proxy_gluesql_example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "sea-orm-proxy-gluesql-example"
version = "0.1.0"
authors = ["Langyo <[email protected]>"]
edition = "2021"
publish = false

[workspace]

[dependencies]
async-std = { version = "1.12", features = ["attributes", "tokio1"] }
serde_json = { version = "1" }
serde = { version = "1" }
futures = { version = "0.3" }
async-stream = { version = "0.3" }
futures-util = { version = "0.3" }

sea-orm = { path = "../../", features = [
"sqlx-all",
"proxy",
"runtime-async-std-native-tls",
"debug-print",
] }
# Since it's newer version (0.14.0) locked the chrono's version to 0.4.23,
# we need to lock it on older version too.
# Related to https://github.com/gluesql/gluesql/pull/1427
gluesql = { version = "0.13", default-features = false, features = [
"memory-storage",
] }

[dev-dependencies]
smol = { version = "1.2" }
smol-potat = { version = "1.1" }
7 changes: 7 additions & 0 deletions examples/proxy_gluesql_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SeaORM Proxy Demo for GlueSQL

Run this demo for [GlueSQL](https://gluesql.org/) with the following command:

```bash
cargo run
```
1 change: 1 addition & 0 deletions examples/proxy_gluesql_example/src/entity/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod post;
17 changes: 17 additions & 0 deletions examples/proxy_gluesql_example/src/entity/post.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,

pub title: String,
pub text: String,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
Loading

0 comments on commit 2844d03

Please sign in to comment.