Open SimTheFool opened 1 year ago
Hello there, I had the same issue. Has anyone found a solution yet?
I had the same problem for around a month and found a workaround today.
Instead of using .run(&mut self.conn)
, I use the undocumented, but existing .run_direct(&mut self.conn)
.
(Look for run_direct
in https://docs.rs/crate/sqlx-core/0.6.3/source/src/migrate/migrator.rs)
With this your migrate
would look like:
async fn migrate(&mut self) -> () {
sqlx::migrate!("./migrations")
.run_direct(&mut self.conn)
.await
.unwrap();
}
As far as I know the Future created by sqlx::migrate!(...).run(...)
is itself or with its data not Send
, but the marker Send
is needed by the async runtime.
It looks like this is could be a bug in Rust itself or the Migrator created by sqlx::migrate(...)
has to be made Send
, BUT I don't know for sure as I also don't have enough knowledge.
Bug Description
When trying to implement a trait async function, that error spaws. It works well outside traits.
Minimal Reproduction
Here is a playground with struct and trait, en dependencies involved.
Info
rustc --version
: rustc 1.69.0 (84c898d65 2023-04-16)