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

Refinery not compatible anymore with mysql_async 0.30.0 #229

Closed
Christoph-AK opened this issue Jun 17, 2022 · 5 comments
Closed

Refinery not compatible anymore with mysql_async 0.30.0 #229

Christoph-AK opened this issue Jun 17, 2022 · 5 comments

Comments

@Christoph-AK
Copy link
Contributor

After upgrading from mysql_async 0.29.0 to 0.30.0 my program won't compile anymore.

The error:

error[E0277]: the trait bound `Pool: AsyncMigrate` is not satisfied
   --> src\main.rs:88:46
    |
88  |     embedded::migrations::runner().run_async(&mut pool).await?;
    |                                    --------- ^^^^^^^^^ the trait `AsyncMigrate` is not implemented for `Pool`
    |                                    |
    |                                    required by a bound introduced by this call
    |
note: required by a bound in `Runner::run_async`
   --> C:\Users\local\.cargo\registry\src\jackfan.us.kg-1ecc6299db9ec823\refinery-core-0.8.4\src\runner.rs:387:12
    |
387 |         C: AsyncMigrate + Send,
    |            ^^^^^^^^^^^^ required by this bound in `Runner::run_async`

My dependency entries:

refinery = { version = "0.8.4", features = ["mysql_async"] }
mysql_async = "0.30.0"

My code:

mod embedded {
    use refinery::embed_migrations;
    embed_migrations!("./migrations");
}

pub fn db_connect(overwrite_db: Option<&str>) -> Result<Pool> {
    let db_name = match overwrite_db {
        Some(d) => d.to_string(),
        None => dotenv::var("DBNAME").unwrap(),
    };
    let dbstring = format!(
        "mysql://{}:{}@{}:{}/{}",
        &dotenv::var("DBUSER").unwrap(),
        &dotenv::var("DBPW").unwrap(),
        &dotenv::var("DBADDRESS").unwrap(),
        &dotenv::var("DBPORT").unwrap(),
        db_name
    );

    // Timeoutes wegen AWS RDS Autosleep erhöhen
    let opts = Opts::from_url(&dbstring).unwrap();
    let opts = OptsBuilder::from_opts(opts)
        .wait_timeout(Some(5 * 60))
        .tcp_keepalive(Some(5 * 60 * 1000u32));

    Ok(Pool::new(opts))
}

async fn main() -> Result<()> {
    ....
    let mut pool = db_connect(None)?;

    embedded::migrations::runner().run_async(&mut pool).await?;
    ....
}

Can I fix this in my code, or does one of the crates need to be updated?

@Christoph-AK
Copy link
Contributor Author

I worked around this by converting my dbstring into a config with the url crate and using that for the run_async.
It's not elegant and requires another dependency, so I'd love to revert it to the 'correct' way using the run_async-pool again one day.

@jxs
Copy link
Member

jxs commented Jun 17, 2022

Hi, thanks for your interest!
Yeah we need to add 0.30 to the dependencies here.
Want to submit a PR?
Thanks!

@Christoph-AK
Copy link
Contributor Author

Christoph-AK commented Jun 20, 2022

Thanks for the pointer!
I needed to change a line adding a deref, but then everything seems to be working.
According to the cargo toml refinery should be compatible back up to mysql-async 0.28, but compiling with 0.28 gives a compiler error:

error[E0432]: unresolved import `mio::net`
  --> C:\Users\local\.cargo\registry\src\jackfan.us.kg-1ecc6299db9ec823\mysql_async-0.28.1\src\io\mod.rs:14:10
   |
14 | use mio::net::{TcpKeepalive, TcpSocket};
   |          ^^^ could not find `net` in `mio`

error[E0599]: no function or associated item named `new` found for struct `mio::Poll` in the current scope
   --> C:\Users\local\.cargo\registry\src\jackfan.us.kg-1ecc6299db9ec823\mysql_async-0.28.1\src\io\mod.rs:378:43
    |
378 |                 let mut poll = mio::Poll::new()?;
    |                                           ^^^ function or associated item not found in `mio::Poll`

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `mysql_async` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

I dont really want to dig into this one, should I just change the version range to 0.29 to 0.30 for now?

Edit: 0.28.0 works, 0.28.1 doesn't.

@Christoph-AK
Copy link
Contributor Author

This is working nicely!
Can we get this released as new version soon? Specifying the commit in cargo slows down the updates by quite a bit (sparse-registries ftw!)

@jxs
Copy link
Member

jxs commented Jul 8, 2022

Hi, yeah no worries I can cut a minor :) I'll do that today

@jxs jxs closed this as completed Jul 8, 2022
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