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 `diesel::Connection` is not implemented for `std::result::Result<diesel::sqlite::SqliteConnection, diesel::ConnectionError>` #581

Closed
adals opened this Issue Jan 18, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@adals

adals commented Jan 18, 2017

hello

here is my code i got error

#![feature(plugin)]
#![plugin(rocket_codegen)]
#![feature(proc_macro)]

extern crate rocket;

#[macro_use] extern crate rocket_contrib;

#[macro_use] extern crate diesel;

#[macro_use] extern crate diesel_codegen;

pub mod schema;
pub mod models;

use diesel::prelude::;
use diesel::sqlite::SqliteConnection;
use models::
;
use rocket_contrib::Template;
use std::result::*;

#[get("/")]
fn index() -> Template {
use schema::users::dsl::*;
let sqlconn=SqliteConnection::establish("dddd.db");
let results = users.filter(published.eq(true))
.limit(5)
.load::(&sqlconn);
let aa="";

Template::render("index",&aa)

}

fn main() {
rocket::ignite().mount("/", routes![index]).launch()

}

/Users/adelalharbi/.cargo/bin/cargo run --color=always
Compiling accountant v0.1.0 (file:///Users/adelalharbi/Codes/Rust/Accountant)
error[E0277]: the trait bound std::string::String: diesel::types::FromSqlRow<diesel::types::Nullable<diesel::types::Bool>, _> is not satisfied
--> src/main.rs:29:10
|
29 | .load::(&sqlconn);
| ^^^^ the trait diesel::types::FromSqlRow<diesel::types::Nullable<diesel::types::Bool>, _> is not implemented for std::string::String
|
= help: the following implementations were found:
<std::string::String as diesel::types::FromSqlRow<diesel::types::Text, DB>>
<std::string::String as diesel::types::FromSqlRow<diesel::types::Date, DB>>
<std::string::String as diesel::types::FromSqlRow<diesel::types::Time, DB>>
<std::string::String as diesel::types::FromSqlRow<diesel::types::Timestamp, DB>>
= note: required because of the requirements on the impl of diesel::types::FromSqlRow<(diesel::types::Integer, diesel::types::Nullable<diesel::types::Bool>), _> for (i32, std::string::String)
= note: required because of the requirements on the impl of diesel::Queryable<(diesel::types::Integer, diesel::types::Nullable<diesel::types::Bool>), _> for models::User

error[E0277]: the trait bound std::result::Result<diesel::sqlite::SqliteConnection, diesel::ConnectionError>: diesel::Connection is not satisfied
--> src/main.rs:29:10
|
29 | .load::(&sqlconn);
| ^^^^ the trait diesel::Connection is not implemented for std::result::Result<diesel::sqlite::SqliteConnection, diesel::ConnectionError>

error: aborting due to 2 previous errors

error: Could not compile accountant.

To learn more, run the command again with --verbose.

@sgrif

This comment has been minimized.

Member

sgrif commented Jan 18, 2017

You need to unwrap the result or handle the possible error.

@sgrif sgrif closed this Jan 18, 2017

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