Diesel Problem when loading

Hi ,
I have a message which is
' the trait diesel::Queryable<diesel::sql_types::Text, _> is not implemented for schema::myapp_carbrand::table ' when executed the line containing load

let connection = establish_connection();
let results = myapp_carbrand.select(brand)
.limit(5)
.load::<myapp_carbrand>(&connection)
.expect("Error loading posts");

Here is my model file associate
#[derive(Queryable, Debug, Identifiable)]
#[table_name = "myapp_carbrand"]
pub struct MyappCarbrand {
pub id: i32,
pub brand: String,
}
I saw that the derive Queryable allow all selection in the table
I am not sure to understand how it works, I want just to do a select on a table

Please help

Thanks in advance

Didier

Please read our pinned post on syntax highlighting.

You are using the table name as the generic argument to load, but you should be using the name of the struct.

I already correct that
Now I have this message during compilation

|
43 | .load::(&connection)
| ^^^^ the trait diesel::Queryable<diesel::sql_types::Text, _> is not implemented for (i32, std::string::String)
|
= help: the following implementations were found:
<(A, B) as diesel::Queryable<(SA, SB), __DB>>
<(A, B) as diesel::Queryable<diesel::sql_types::Record<(SA, SB)>, diesel::pg::Pg>>
<(std::collections::Bound, std::collections::Bound) as diesel::Queryable<diesel::sql_types::Range, diesel::pg::Pg>>
= note: required because of the requirements on the impl of diesel::Queryable<diesel::sql_types::Text, _> for models::MyappCarbrand
= 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::brand>>

Please read the post I linked above and edit your posts to use correct formatting for both code and errors messages.

I already correct that
Here is my code
...rust
fn main() {
use schema::myapp_carbrand::dsl::*;
let connection = establish_connection();
let results = myapp_carbrand.select(brand)
//.limit(5)
.load::(&connection)
.expect("Error loading posts");

println!("Displaying {:?} posts", results);

for _post in results {
    println!("{:?}", _post);
    println!("----------\n");
    //println!("{:?}", _post);
}

}
...
Now I have this message during compilation

|
43 | .load::(&connection)
| ^^^^ the trait diesel::Queryable<diesel::sql_types::Text, _> is not implemented for (i32, std::string::String)
|
= help: the following implementations were found:
<(A, B) as diesel::Queryable<(SA, SB), __DB>>
<(A, B) as diesel::Queryable<diesel::sql_types::Record<(SA, SB)>, diesel::pg::Pg>>
<(std::collections::Bound, std::collections::Bound) as diesel::Queryable<diesel::sql_types::Range, diesel::pg::Pg>>
= note: required because of the requirements on the impl of diesel::Queryable<diesel::sql_types::Text, _> for models::MyappCarbrand
= 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::brand>>

You need to use a backtick character instead of a period. Please edit the existing posts instead of posting new ones, and note that this forum supports a preview feature, so you can see if it is working before post.

I already correct that
Here is my code

fn main() {
use schema::myapp_carbrand::dsl::*;
let connection = establish_connection();
let results = myapp_carbrand.select(brand)
.limit(5)
.load::(&connection)
.expect("Error loading posts");


println!("Displaying {:?} posts", results);

for _post in results {
    println!("{:?}", _post);
    println!("----------\n");
    //println!("{:?}", _post);
}

}
...
Now I have this message during compilation

|
43 | .load::(&connection)
| ^^^^ the trait diesel::Queryable<diesel::sql_types::Text, _> is not implemented for (i32, std::string::String)
|
= help: the following implementations were found:
<(A, B) as diesel::Queryable<(SA, SB), __DB>>
<(A, B) as diesel::Queryable<diesel::sql_types::Record<(SA, SB)>, diesel::pg::Pg>>
<(std::collections::Bound, std::collections::Bound) as diesel::Queryable<diesel::sql_types::Range, diesel::pg::Pg>>
= note: required because of the requirements on the impl of diesel::Queryable<diesel::sql_types::Text, _> for models::MyappCarbrand
= 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::brand>>

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.