digital-society-coop / axum-sqlx-tx

Request-scoped sqlx transactions for axum
MIT License
45 stars 11 forks source link

Library Not Compatible with Axum v0.7 #31

Closed RobbieMcKinstry closed 6 months ago

RobbieMcKinstry commented 7 months ago

Hello!

Have you been able to upgrade an existing Axum app that uses this library to v0.7.0?

When upgrading to Axum 0.7 and using the Tx extractor, I get an error:

error[E0277]: the trait bound `axum_sqlx_tx::Tx<sqlx::Postgres>: axum::extract::FromRequestParts<std::sync::Arc<(dyn object_store::ObjectStore + 'static)>>` is not satisfied
  --> src/routes/accounts/packages/create.rs:40:13
   |
40 |     mut tx: Tx<Postgres>,
   |             ^^ the trait `axum::extract::FromRequestParts<std::sync::Arc<(dyn object_store::ObjectStore + 'static)>>` is not implemented for `axum_sqlx_tx::Tx<sqlx::Postgres>`
   |
   = help: the following other types implement trait `axum::extract::FromRequestParts<S>`:
             <axum::http::HeaderMap as axum::extract::FromRequestParts<S>>
             <axum::Extension<T> as axum::extract::FromRequestParts<S>>
             <axum::http::Method as axum::extract::FromRequestParts<S>>
             <axum::http::request::Parts as axum::extract::FromRequestParts<S>>
             <axum::http::Uri as axum::extract::FromRequestParts<S>>
             <axum::http::Version as axum::extract::FromRequestParts<S>>
             <axum::http::Extensions as axum::extract::FromRequestParts<S>>
             <axum::extract::ConnectInfo<T> as axum::extract::FromRequestParts<S>>
           and 28 others
   = help: see issue #48214

Note that the type std::sync::Arc<(dyn object_store::ObjectStore + 'static)> is another extractor, using axum's builtin State<T> extractor. I get this same issue on different routes with different values of T for State<T>. The issue persists if I reorder the parameters.

From what I can tell, I believe this library is no longer compatible with the latest Axum release, v0.7.0. It's only been out for a few days, and there are a ton of breaking changes, so I wouldn't really be surprised if this were the case. However, I could be wrong, and the error could be in my source code. Here's the intel I've gathered that leads me to believe the issue is in axum-sqlx-tx:

Thank you for your time and attention to this issue. ❤️

connec commented 7 months ago

You're correct – I'll need to update this library for axum 0.7, which I'll see if I can get to in the next couple of days. Hopefully things should be simpler with the upgrade, now that the Body generic is gone 🤞

RobbieMcKinstry commented 7 months ago

Thank you very much. I appreciate your promptness, and your willingness to make the upgrade! 🚀 ❤️ ✨

connec commented 6 months ago

Apologies for the delay! There was a more awkward element to the upgrade than I'd hoped (implementing Clone for request extensions), but I've just published 0.8.0 with support for axum 0.7.0 / hyper 1.0!

RobbieMcKinstry commented 5 months ago

Hey there! Thank you very much for resolving this issue and cutting a release! Last night, I was able to upgrade my web sever to the new version. 🚀 Thanks again! ✨