Skip to content

Commit 3c9e976

Browse files
authored
Merge pull request #13 from weiznich/update_to_diesel_master
Update to diesels master branch
2 parents 7266ca4 + adbe106 commit 3c9e976

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

Cargo.lock

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ postgres = ["diesel/postgres_backend", "tokio-postgres", "tokio", "tokio/rt-mult
3636
name = "integration_tests"
3737
path = "tests/lib.rs"
3838
harness = true
39+
40+
[patch.crates-io]
41+
diesel = {git = "https://github.com/diesel-rs/diesel", branch = "master"}

src/lib.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,16 @@ where
224224
Self::TransactionManager::commit_transaction(self).await?;
225225
Ok(value)
226226
}
227-
Err(e) => {
228-
Self::TransactionManager::rollback_transaction(self)
229-
.await
230-
.map_err(|e| diesel::result::Error::RollbackError(Box::new(e)))?;
231-
Err(e)
227+
Err(user_error) => {
228+
match Self::TransactionManager::rollback_transaction(self).await {
229+
Ok(()) => Err(user_error),
230+
Err(diesel::result::Error::BrokenTransactionManager) => {
231+
// In this case we are probably more interested by the
232+
// original error, which likely caused this
233+
Err(user_error)
234+
}
235+
Err(rollback_error) => Err(rollback_error.into()),
236+
}
232237
}
233238
}
234239
}

src/pg/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,16 @@ impl AsyncConnection for AsyncPgConnection {
215215
Self::TransactionManager::commit_transaction(self).await?;
216216
Ok(value)
217217
}
218-
Err(e) => {
219-
Self::TransactionManager::rollback_transaction(self)
220-
.await
221-
.map_err(|e| diesel::result::Error::RollbackError(Box::new(e)))?;
222-
Err(e)
218+
Err(user_error) => {
219+
match Self::TransactionManager::rollback_transaction(self).await {
220+
Ok(()) => Err(user_error),
221+
Err(diesel::result::Error::BrokenTransactionManager) => {
222+
// In this case we are probably more interested by the
223+
// original error, which likely caused this
224+
Err(user_error)
225+
}
226+
Err(rollback_error) => Err(rollback_error.into()),
227+
}
223228
}
224229
}
225230
}

0 commit comments

Comments
 (0)