Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acquire lifetime errors in axum handlers #1686

Closed
stoically opened this issue Feb 7, 2022 · 2 comments
Closed

Acquire lifetime errors in axum handlers #1686

stoically opened this issue Feb 7, 2022 · 2 comments

Comments

@stoically
Copy link
Contributor

stoically commented Feb 7, 2022

When trying to use Acquire and passing in a transaction inside an axum handler I get the following lifetime error:

error: implementation of `sqlx::Acquire` is not general enough
  --> src/lib.rs:10:9
   |
10 |         get(|| async move {
   |         ^^^ implementation of `sqlx::Acquire` is not general enough
   |
   = note: `sqlx::Acquire<'1>` would have to be implemented for the type `&'0 mut Transaction<'_, Postgres>`, for any two lifetimes `'0` and `'1`...
   = note: ...but `sqlx::Acquire<'2>` is actually implemented for the type `&'2 mut Transaction<'_, Postgres>`, for some specific lifetime `'2`

Executable example: https://github.com/stoically/sqlx-axum-acquire-issue/blob/main/src/lib.rs

@pythoneer
Copy link

Is this issue related?

@stoically
Copy link
Contributor Author

@pythoneer It is and #1015 (comment) actually solves the issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants