Hi Everyone,
I try to use Diesel as ORM with Rust
I have created the model which is
#[derive( Debug, Identifiable)]
#[table_name = "myapp_carbrand"]
pub struct MyappCarbrand {
pub id: i32,
pub brand: String,
}
Here is the schema
table! {
myapp_carbrand (id) {
id -> Int4,
brand -> Varchar,
}
}
impl Queryable<myapp_carbrand::SqlType, DB> for MyappCarbrand {
type Row = (i32, String);
fn build(row: Self::Row) -> Self {
MyappCarbrand {
id: row.0,
brand: row.1,
}
}
}
Here is the main program
fn main() {
use schema::myapp_carbrand::dsl::*;
let connection = establish_connection();
let results = myapp_carbrand.select(id)
//.limit(5)
.load::<MyappCarbrand>(&connection)
.expect("Error loading posts");
println!("Displaying {:?} posts", results);
for _post in results {
println!("{:?}", _post);
println!("----------\n");
//println!("{:?}", _post);
}
}
I have the error message during the compilation
.load::<MyappCarbrand>(&connection)
| ^^^^ the trait `diesel::Queryable<diesel::sql_types::Integer, _>` is not implemented for `models::MyappCarbrand`
|
= help: the following implementations were found:
<models::MyappCarbrand as diesel::Queryable<(diesel::sql_types::Integer, diesel::sql_types::Text), diesel::pg::Pg>>
= note: required because of the requirements on the impl of `diesel::query_dsl::LoadQuery<_, models::MyappCarbrand>` for `diesel::query_builder::SelectStatement<schema::myapp_carbrand::table, diesel::query_builder::select_clause::SelectClause<schema::myapp_carbrand::columns::id>>`
As I am new to Rust Please could you help me to solve the issue
Didier