Skip to content

Commit 584234c

Browse files
committed
update to tokio-postgres 0.6, deadpool support
1 parent f4f5a26 commit 584234c

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

postgres_query/Cargo.toml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ path = "examples/basic.rs"
1717

1818
[dependencies]
1919
postgres_query_macro = { version = "0.3.1", path = "../postgres_query_macro" }
20-
proc-macro-hack = "0.5.11"
21-
postgres-types = "0.1.0"
22-
serde = "1.0.104"
23-
tokio-postgres = "0.5.1"
24-
futures = "0.3.1"
25-
async-trait = "0.1.22"
26-
thiserror = "1.0.9"
20+
proc-macro-hack = "0.5.19"
21+
postgres-types = "0.1.3"
22+
serde = "1.0.117"
23+
tokio-postgres = "0.6.0"
24+
deadpool-postgres = "0.6.0"
25+
futures = "0.3.8"
26+
async-trait = "0.1.41"
27+
thiserror = "1.0.22"
2728

2829
[dev-dependencies]
29-
bytes = "0.5.3"
30-
tokio = { version = "0.2.6", features = ["macros"] }
31-
structopt = "0.3.7"
32-
anyhow = "1.0.26"
30+
bytes = "0.6.0"
31+
tokio = { version = "0.3.3", features = ["macros", "rt-multi-thread"] }
32+
structopt = "0.3.20"
33+
anyhow = "1.0.34"

postgres_query/src/client.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub use cache::Caching;
77
use async_trait::async_trait;
88
use postgres_types::ToSql;
99
use tokio_postgres::{error::Error as SqlError, Client, RowStream, Statement, Transaction};
10+
use deadpool_postgres::{Client as DPClient};
1011

1112
/// A generic client with basic functionality.
1213
#[async_trait]
@@ -80,6 +81,29 @@ impl GenericClient for Client {
8081
}
8182
}
8283

84+
#[async_trait]
85+
impl GenericClient for DPClient {
86+
async fn prepare(&self, sql: &str) -> Result<Statement, SqlError> {
87+
DPClient::prepare(self, sql).await
88+
}
89+
90+
async fn execute_raw<'a>(
91+
&'a self,
92+
statement: &Statement,
93+
parameters: &[&'a (dyn ToSql + Sync)],
94+
) -> Result<u64, SqlError> {
95+
DPClient::execute_raw(self, statement, parameters).await
96+
}
97+
98+
async fn query_raw<'a>(
99+
&'a self,
100+
statement: &Statement,
101+
parameters: &[&'a (dyn ToSql + Sync)],
102+
) -> Result<RowStream, SqlError> {
103+
DPClient::query_raw(self, statement, parameters).await
104+
}
105+
}
106+
83107
#[async_trait]
84108
impl GenericClient for Transaction<'_> {
85109
async fn prepare(&self, sql: &str) -> Result<Statement, SqlError> {

postgres_query_macro/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "postgres_query_macro"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
authors = ["Christofer Nolander <christofer.nolander@gmail.com>"]
55
edition = "2018"
66
description = "Write and execute SQL queries with ease"
@@ -12,7 +12,7 @@ readme = "../README.md"
1212
proc-macro = true
1313

1414
[dependencies]
15-
proc-macro-hack = "0.5.11"
16-
quote = "1.0.2"
17-
syn = { version = "1.0.11", features = ["full"] }
18-
proc-macro2 = "1.0.6"
15+
proc-macro-hack = "0.5.19"
16+
quote = "1.0.7"
17+
syn = { version = "1.0.48", features = ["full"] }
18+
proc-macro2 = "1.0.24"

0 commit comments

Comments
 (0)