Skip to content

Commit d396123

Browse files
caelunshunjbr
authored andcommitted
Update to sqlx 0.4
1 parent aa36fab commit d396123

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ categories = ["web-programming::http-server", "web-programming", "database"]
1414
[package.metadata.docs.rs]
1515
features = ["pg", "sqlite"]
1616

17-
[features]
18-
default = []
17+
[features]
18+
default = ["native-tls"]
1919
sqlite = ["sqlx/sqlite"]
2020
pg = ["sqlx/postgres", "sqlx/json"]
21+
native-tls = ["sqlx/runtime-async-std-native-tls"]
22+
rustls = ["sqlx/runtime-async-std-rustls"]
2123

2224
[dependencies]
2325
async-session = "2.0.1"
24-
sqlx = { version = "0.3.5", features = ["chrono"] }
25-
async-std = "1.7.0"
26-
26+
sqlx = { version = "0.4.1", features = ["chrono"] }
27+
async-std = "1.8.0"
2728

2829
[dev-dependencies]
29-
async-std = { version = "1.7.0", features = ["attributes"] }
30+
async-std = { version = "1.8.0", features = ["attributes"] }

src/pg.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use async_session::{async_trait, chrono::Utc, log, serde_json, Result, Session, SessionStore};
22
use async_std::task;
3-
use sqlx::{pool::PoolConnection, prelude::PgQueryAs, Executor, PgConnection, PgPool};
3+
use sqlx::{pool::PoolConnection, Executor, Postgres, PgPool};
44
use std::time::Duration;
55

66
/// sqlx postgres session store for async-sessions
@@ -69,7 +69,7 @@ impl PostgresSessionStore {
6969
/// # Ok(()) }) }
7070
/// ```
7171
pub async fn new(database_url: &str) -> sqlx::Result<Self> {
72-
let pool = PgPool::new(database_url).await?;
72+
let pool = PgPool::connect(database_url).await?;
7373
Ok(Self::from_client(pool))
7474
}
7575

@@ -169,7 +169,7 @@ impl PostgresSessionStore {
169169
}
170170

171171
/// retrieve a connection from the pool
172-
async fn connection(&self) -> sqlx::Result<PoolConnection<PgConnection>> {
172+
async fn connection(&self) -> sqlx::Result<PoolConnection<Postgres>> {
173173
self.client.acquire().await
174174
}
175175

src/sqlite.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use async_session::{async_trait, chrono::Utc, log, serde_json, Result, Session, SessionStore};
22
use async_std::task;
3-
use sqlx::{pool::PoolConnection, prelude::SqliteQueryAs, sqlite::SqlitePool, SqliteConnection};
3+
use sqlx::{pool::PoolConnection, sqlite::SqlitePool, Sqlite};
44
use std::time::Duration;
55

66
/// sqlx sqlite session store for async-sessions
@@ -71,7 +71,7 @@ impl SqliteSessionStore {
7171
/// # Ok(()) }) }
7272
/// ```
7373
pub async fn new(database_url: &str) -> sqlx::Result<Self> {
74-
Ok(Self::from_client(SqlitePool::new(database_url).await?))
74+
Ok(Self::from_client(SqlitePool::connect(database_url).await?))
7575
}
7676

7777
/// constructs a new SqliteSessionStore from a sqlite: database url. the
@@ -172,7 +172,7 @@ impl SqliteSessionStore {
172172
}
173173

174174
/// retrieve a connection from the pool
175-
async fn connection(&self) -> sqlx::Result<PoolConnection<SqliteConnection>> {
175+
async fn connection(&self) -> sqlx::Result<PoolConnection<Sqlite>> {
176176
self.client.acquire().await
177177
}
178178

0 commit comments

Comments
 (0)