Skip to content

Commit d179e82

Browse files
committed
Merge pull request #704 from SeaQL/diesel
Diesel Integration
1 parent fe2d243 commit d179e82

File tree

18 files changed

+1988
-0
lines changed

18 files changed

+1988
-0
lines changed

Diff for: .github/workflows/diesel.yml

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: diesel-tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/diesel.yml'
7+
- 'examples/diesel_*/**'
8+
- 'sea-query-diesel/**'
9+
push:
10+
branches:
11+
- master
12+
- 0.*.x
13+
- pr/**/ci
14+
- ci-*
15+
paths:
16+
- '.github/workflows/diesel.yml'
17+
- 'examples/diesel_*/**'
18+
- 'sea-query-diesel/**'
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
22+
cancel-in-progress: true
23+
24+
env:
25+
CARGO_TERM_COLOR: always
26+
27+
jobs:
28+
rustfmt:
29+
name: Rustfmt
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: dtolnay/rust-toolchain@master
34+
with:
35+
toolchain: nightly
36+
components: rustfmt
37+
- run: cargo fmt --manifest-path examples/diesel_sqlite/Cargo.toml --all -- --check
38+
- run: cargo fmt --manifest-path examples/diesel_postgres/Cargo.toml --all -- --check
39+
- run: cargo fmt --manifest-path examples/diesel_mysql/Cargo.toml --all -- --check
40+
41+
diesel-build:
42+
name: Build `sea-query-diesel`
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v3
46+
- uses: dtolnay/rust-toolchain@stable
47+
- run: cargo update --manifest-path sea-query-diesel/Cargo.toml --workspace -p bigdecimal:0.4.1 --precise 0.3.1
48+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-chrono,with-json,with-rust_decimal,with-bigdecimal,with-uuid,with-time,with-ipnetwork,with-mac_address,postgres-array
49+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-chrono
50+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-json
51+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-rust_decimal
52+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres --features=with-rust_decimal-postgres
53+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features mysql --features=with-rust_decimal-mysql
54+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-bigdecimal
55+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-uuid
56+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-time
57+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-ipnetwork
58+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-mac_address
59+
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=postgres-array
60+
61+
sqlite:
62+
name: SQLite
63+
runs-on: ubuntu-latest
64+
needs: diesel-build
65+
strategy:
66+
matrix:
67+
example: [diesel_sqlite]
68+
steps:
69+
- uses: actions/checkout@v3
70+
- uses: dtolnay/rust-toolchain@stable
71+
- run: cargo build --manifest-path examples/${{ matrix.example }}/Cargo.toml
72+
- run: cargo run --manifest-path examples/${{ matrix.example }}/Cargo.toml
73+
74+
mysql:
75+
name: MySQL
76+
runs-on: ubuntu-latest
77+
needs: diesel-build
78+
strategy:
79+
matrix:
80+
version: [8.0, 5.7]
81+
example: [diesel_mysql]
82+
services:
83+
mysql:
84+
image: mysql:${{ matrix.version }}
85+
env:
86+
MYSQL_HOST: 127.0.0.1
87+
MYSQL_DATABASE: query
88+
MYSQL_USER: sea
89+
MYSQL_PASSWORD: sea
90+
MYSQL_ROOT_PASSWORD: sea
91+
ports:
92+
- "3306:3306"
93+
options: >-
94+
--health-cmd="mysqladmin ping"
95+
--health-interval=10s
96+
--health-timeout=5s
97+
--health-retries=3
98+
steps:
99+
- uses: actions/checkout@v3
100+
- uses: dtolnay/rust-toolchain@stable
101+
- run: cargo build --manifest-path examples/${{ matrix.example }}/Cargo.toml
102+
- run: cargo run --manifest-path examples/${{ matrix.example }}/Cargo.toml
103+
104+
mariadb:
105+
name: MariaDB
106+
runs-on: ubuntu-latest
107+
needs: diesel-build
108+
strategy:
109+
matrix:
110+
version: [10.6]
111+
example: [diesel_mysql]
112+
services:
113+
mariadb:
114+
image: mariadb:${{ matrix.version }}
115+
env:
116+
MYSQL_HOST: 127.0.0.1
117+
MYSQL_DATABASE: query
118+
MYSQL_USER: sea
119+
MYSQL_PASSWORD: sea
120+
MYSQL_ROOT_PASSWORD: sea
121+
ports:
122+
- "3306:3306"
123+
options: >-
124+
--health-cmd="mysqladmin ping"
125+
--health-interval=10s
126+
--health-timeout=5s
127+
--health-retries=3
128+
steps:
129+
- uses: actions/checkout@v3
130+
- uses: dtolnay/rust-toolchain@stable
131+
- run: cargo build --manifest-path examples/${{ matrix.example }}/Cargo.toml
132+
- run: cargo run --manifest-path examples/${{ matrix.example }}/Cargo.toml
133+
134+
postgres:
135+
name: PostgreSQL
136+
runs-on: ubuntu-latest
137+
needs: diesel-build
138+
strategy:
139+
matrix:
140+
version: [14.4, 13.7, 12.11]
141+
example: [diesel_postgres]
142+
services:
143+
postgres:
144+
image: postgres:${{ matrix.version }}
145+
env:
146+
POSTGRES_HOST: 127.0.0.1
147+
POSTGRES_DB: query
148+
POSTGRES_USER: sea
149+
POSTGRES_PASSWORD: sea
150+
ports:
151+
- "5432:5432"
152+
options: >-
153+
--health-cmd pg_isready
154+
--health-interval 10s
155+
--health-timeout 5s
156+
--health-retries 5
157+
steps:
158+
- uses: actions/checkout@v3
159+
- uses: dtolnay/rust-toolchain@stable
160+
- run: cargo update --manifest-path examples/${{ matrix.example }}/Cargo.toml -p bigdecimal:0.4.1 --precise 0.3.1
161+
- run: cargo build --manifest-path examples/${{ matrix.example }}/Cargo.toml
162+
- run: cargo run --manifest-path examples/${{ matrix.example }}/Cargo.toml

Diff for: examples/diesel_mysql/Cargo.toml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[workspace]
2+
# A separate workspace
3+
4+
[package]
5+
name = "sea-query-diesel-mysql-example"
6+
version = "0.1.0"
7+
edition = "2021"
8+
9+
[dependencies]
10+
chrono = { version = "0.4", default-features = false, features = ["clock"] }
11+
time = { version = "0.3", features = ["parsing", "macros"] }
12+
serde_json = { version = "1" }
13+
uuid = { version = "1", features = ["serde", "v4"] }
14+
diesel = { version = "2.1.1", features = ["mysql"] }
15+
sea-query = { path = "../.." }
16+
sea-query-diesel = { path = "../../sea-query-diesel", features = [
17+
"mysql",
18+
"with-chrono",
19+
"with-json",
20+
"with-uuid",
21+
"with-time",
22+
] }
23+
24+
# NOTE: if you are copying this example into your own project, use the following line instead:
25+
# sea-query = { version = "0"}
26+
# sea-query-diesel = { version = "0", features = [...] }

Diff for: examples/diesel_mysql/Readme.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SeaQuery Diesel MySQL example
2+
3+
Running:
4+
5+
```sh
6+
cargo run
7+
```
8+
9+
Example output:
10+
11+
```
12+
Create table character: Ok(())
13+
14+
Insert into character Ok(4)
15+
16+
Select one from character:
17+
CharacterStructChrono { id: 4, uuid: UUID(3a23c42d-8cd9-4a0f-a8c3-0ced15d42228), name: "A", font_size: 12, meta: Object {"notes": String("some notes here")}, created: Some(2020-01-01T02:02:02) }
18+
19+
Select one from character:
20+
CharacterStructTime { id: 4, uuid: UUID(3a23c42d-8cd9-4a0f-a8c3-0ced15d42228), name: "A", font_size: 12, meta: Object {"notes": String("some notes here")}, created: Some(2020-01-01 2:02:02.0) }
21+
22+
23+
Update character: Ok(1)
24+
25+
Select one from character:
26+
CharacterStructChrono { id: 4, uuid: UUID(3a23c42d-8cd9-4a0f-a8c3-0ced15d42228), name: "A", font_size: 24, meta: Object {"notes": String("some notes here")}, created: Some(2020-01-01T02:02:02) }
27+
28+
Select one from character:
29+
CharacterStructTime { id: 4, uuid: UUID(3a23c42d-8cd9-4a0f-a8c3-0ced15d42228), name: "A", font_size: 24, meta: Object {"notes": String("some notes here")}, created: Some(2020-01-01 2:02:02.0) }
30+
31+
32+
Count character: Ok(CountField { count: 4 })
33+
34+
Delete character: Ok(1)
35+
```

0 commit comments

Comments
 (0)