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

the trait bound `r2d2::PooledConnection<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>: diesel::Connection` is not satisfied #339

Closed
xiaofann opened this Issue May 21, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@xiaofann

xiaofann commented May 21, 2016

use r2d2-diesel = {git = "https://github.com/diesel-rs/r2d2-diesel"} for thread pool, when i cargo build have the error message.
the trait bound r2d2::PooledConnection<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>: diesel::Connection is not satisfied

lib version info:
dependencies = [
"diesel 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel_codegen 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"r2d2 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"r2d2-diesel 0.6.0 (git+https://github.com/diesel-rs/r2d2-diesel)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
]

source:

![feature(custom_derive, custom_attribute, plugin)]

![plugin(diesel_codegen)]

[macro_use]extern crate diesel;

extern crate r2d2;
extern crate r2d2_diesel;

[macro_use]extern crate lazy_static;

extern crate rustc_serialize;
extern crate toml;

use diesel::pg::PgConnection;
use r2d2_diesel::ConnectionManager;
use diesel::prelude::*;
use models::Order;

pub mod config;
pub mod models;
pub mod schema;

fn main() {
let config = r2d2::Config::builder().pool_size(config::POOL_SIZE).build();
let manager = ConnectionManager::::new(config::DATABASE_URL.as_str());
let pool = r2d2::Pool::new(config, manager).expect("Failed to create poll");
let connection = pool.get().unwrap();
use self::schema::order::dsl::
;

let results = order.filter(name.eq("xiaobai"))
    .limit(5)
    .load::<Order>(&connection)
    .expect("Error loading posts");

println!("Displaying {} posts", results.len());
for post in results {
    println!("{}", post.name);
    println!("----------\n");
    println!("{}", post.telephone);
}

}

@sgrif

This comment has been minimized.

Member

sgrif commented May 21, 2016

r2d2-diesel is using the latest released version, while your code is using the version from git. You can manually override it with .cargo/config, or clone down r2d2-diesel locally and point it at git.

@sgrif sgrif closed this May 21, 2016

@xiaofann

This comment has been minimized.

xiaofann commented May 23, 2016

forget use deref trait. just add operator * behind & like (&*connection)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment