Open oeed opened 4 years ago
If you clone the repo locally (and also diesel), apply this patch, and it should work.
commit 0fc88e4318604c1293f4e697b00e078412b66277
Author: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Date: Sat Nov 14 10:37:02 2020 +0100
Upgrade tokio to diesel v2
diff --git a/Cargo.toml b/Cargo.toml
index 2a6a50f..636d43d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,12 +10,12 @@ categories = ["asynchronous", "database"]
[dependencies]
async-trait = "0.1.33"
-diesel = { version = "1.4.5", default-features = false, features = [ "r2d2" ] }
+diesel = { path = "../diesel/diesel", default-features = false, features = [ "r2d2" ] }
futures = { version = "0.3.5", default-features = false }
r2d2 = "0.8.8"
tokio = { version = ">=0.2.21", default-features = false, features = [ "blocking", "rt-threaded" ] }
[dev-dependencies]
-diesel = { version = "1.4.4", default-features = false, features = [ "postgres", "uuidv07" ] }
+diesel = { path = "../diesel/diesel", default-features = false, features = [ "postgres", "uuidv07" ] }
uuid = { version = "0.8.1", features = [ "v4" ] }
tokio = { version = ">=0.2.21", default-features = false, features = [ "full" ] }
diff --git a/src/lib.rs b/src/lib.rs
index 1b27a41..49bec3e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,7 +6,7 @@ use diesel::{
methods::{ExecuteDsl, LimitDsl, LoadQuery},
RunQueryDsl,
},
- r2d2::{ConnectionManager, Pool},
+ r2d2::{ConnectionManager, Pool, R2D2Connection},
result::QueryResult,
Connection,
};
@@ -67,7 +67,7 @@ where
#[async_trait]
impl<Conn> AsyncSimpleConnection<Conn> for Pool<ConnectionManager<Conn>>
where
- Conn: 'static + Connection,
+ Conn: 'static + R2D2Connection,
{
#[inline]
async fn batch_execute_async(&self, query: &str) -> AsyncResult<()> {
@@ -99,7 +99,7 @@ where
#[async_trait]
impl<Conn> AsyncConnection<Conn> for Pool<ConnectionManager<Conn>>
where
- Conn: 'static + Connection,
+ Conn: 'static + R2D2Connection,
{
#[inline]
async fn run<R, Func>(&self, f: Func) -> AsyncResult<R>
@@ -163,7 +163,7 @@ where
impl<T, Conn> AsyncRunQueryDsl<Conn, Pool<ConnectionManager<Conn>>> for T
where
T: Send + RunQueryDsl<Conn>,
- Conn: 'static + Connection,
+ Conn: 'static + R2D2Connection,
{
async fn execute_async(self, asc: &Pool<ConnectionManager<Conn>>) -> AsyncResult<usize>
where
I'm aware Diesel version 2 isn't stable yet, so understand if this wouldn't be a priority. However, I've found I can't get the example code for tokio-diesel to compile with the Diesel v2.0/master branch. I'm using it primarily because it avoids the need for
extern crate
, I'm still pretty new to Rust so I had some headaches when forced to useextern crate
.I've made a reproduction using the given
example.rs
file, although note I've replaced UUID with plain integers as it was causing other issues.The full output of the first error is (the second is basically the same but for
SelectStatement
)