Hello everyone,
I'm trying to filter some data of a table depending on a struct called Filter. When I use .load() I get this enormous error:
error[E0277]: the trait bound `(diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Bool, diesel::sql_types::Text, diesel::sql_types::Integer, diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Bool, diesel::sql_types::Timestamp, diesel::sql_types::Bool, diesel::sql_types::Bool, diesel::sql_types::Nullable<diesel::sql_types::Text>): load_dsl::private::CompatibleType<Question, Mysql>` is not satisfied
--> src/question.rs:172:55
|
172 | .filter(subject.eq("mates")).load::<Question>(&mut conn)?;
| ---- ^^^^^^^^^ the trait `load_dsl::private::CompatibleType<Question, Mysql>` is not implemented for `(diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Bool, diesel::sql_types::Text, diesel::sql_types::Integer, diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Bool, diesel::sql_types::Timestamp, diesel::sql_types::Bool, diesel::sql_types::Bool, diesel::sql_types::Nullable<diesel::sql_types::Text>)`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `load_dsl::private::CompatibleType<U, DB>`:
(ST0, ST1)
(ST0, ST1, ST2)
(ST0, ST1, ST2, ST3)
(ST0, ST1, ST2, ST3, ST4)
(ST0, ST1, ST2, ST3, ST4, ST5)
(ST0, ST1, ST2, ST3, ST4, ST5, ST6)
(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7)
(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8)
and 24 others
= note: required for `SelectStatement<FromClause<table>, DefaultSelectClause<FromClause<table>>, NoDistinctClause, WhereClause<Grouped<Eq<subject, Bound<Text, &str>>>>>` to implement `LoadQuery<'_, _, Question>`
= note: the full type name has been written to '/home/juanjo/Documentos/Programación/trivial_packager/target/debug/deps/trivial_packager-969823c3fda829c5.long-type-1694249202718504701.txt'
note: required by a bound in `diesel::RunQueryDsl::load`
--> /home/juanjo/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel-2.0.3/src/query_dsl/mod.rs:1499:15
|
1499 | Self: LoadQuery<'query, Conn, U>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RunQueryDsl::load`
This is the affected part of the code, the full code is here:
fn filter_question_query(filter: Filter, pool: web::Data<Pool>) -> Result<Vec<Question>, ServiceError> {
use crate::schema::questions::dsl::*;
let mut conn = pool.get()?;
let data = questions
.filter(subject.eq("mates")).load::<Question>(&mut conn)?;
Ok(data)
}
A part of the schema.rs for MySqlDB:
diesel::table! {
questions (id) {
id -> Integer,
subject -> Varchar,
level -> Integer,
question -> Varchar,
hide -> Bool,
answers -> Varchar,
tries -> Integer,
time -> Integer,
image -> Varchar,
bigger -> Bool,
created_at -> Timestamp,
verified -> Bool,
modified -> Bool,
creator -> Nullable<Varchar>,
}
}
This issue doesn't happen on other parts of the code while they have in essence the same code.