Problemas with HasSqlType with joins.
Closed this issue · 1 comments
pedrohjordao commented
Hi,
I'm trying to use the following code:
sistemas_de_equipamento.inner_join(avaria)
.filter(AvariaId.eq(avaria_id))
.first(&*conn)
with:
#[derive(Serialize, Queryable, Deserialize)]
pub struct AvariaJson {
pub id: i32,
pub tag: String,
pub descricao: String,
pub flag: f64,
pub taxa: f64,
pub valor: f64,
pub id_sistema: Option<i32>
}
#[derive(Serialize, Queryable, Deserialize)]
pub struct SistemaJson {
pub id: i32,
pub codigo_sistema: String,
pub fxml: String,
pub grupo: TipoGrupo,
pub nome: String
}
#[derive(DbEnum, Serialize, Deserialize)]
#[derive(Debug)]
pub enum TipoGrupo {
PROPULSAO, AUXILIAR, ELETRICA
}
And i'm getting
|
26 | .first(&*conn)
| ^^^^^ the trait `diesel::sql_types::HasSqlType<schema::enum_schemas::TipoGrupo>` is not implemented for `diesel::pg::Pg`
|
= help: the following implementations were found:
<diesel::pg::Pg as diesel::sql_types::HasSqlType<schema::enum_schemas::db_enum_impl_TipoModelo::TipoModeloMapping>>
<diesel::pg::Pg as diesel::sql_types::HasSqlType<schema::enum_schemas::db_enum_impl_TipoInterface::TipoInterfaceMapping>>
<diesel::pg::Pg as diesel::sql_types::HasSqlType<schema::enum_schemas::db_enum_impl_TipoGrupo::TipoGrupoMapping>>
<diesel::pg::Pg as diesel::sql_types::HasSqlType<diesel::sql_types::Inet>>
and 29 others
= note: required because of the requirements on the impl of `diesel::sql_types::HasSqlType<(diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Text, schema::enum_schemas::TipoGrupo, diesel::sql_types::Text)>` for `diesel::pg::Pg`
= note: required because of the requirements on the impl of `diesel::sql_types::HasSqlType<((diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Text, schema::enum_schemas::TipoGrupo, diesel::sql_types::Text), (diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Text, diesel::sql_types::Double, diesel::sql_types::Double, diesel::sql_types::Double, diesel::sql_types::Nullable<diesel::sql_types::Integer>))>` for `diesel::pg::Pg`
= note: required because of the requirements on the impl of `diesel::query_dsl::LoadQuery<diesel::PgConnection, _>` for `diesel::query_builder::SelectStatement<diesel::query_source::joins::JoinOn<diesel::query_source::joins::Join<schema::noctus_schemas::sistemas_de_equipamento::table, schema::noctus_schemas::avaria::table, diesel::query_source::joins::Inner>, diesel::expression::operators::Eq<diesel::expression::nullable::Nullable<schema::noctus_schemas::avaria::columns::id_sistema>, diesel::expression::nullable::Nullable<schema::noctus_schemas::sistemas_de_equipamento::columns::id>>>, diesel::query_builder::select_clause::DefaultSelectClause, diesel::query_builder::distinct_clause::NoDistinctClause, diesel::query_builder::where_clause::WhereClause<diesel::expression::operators::Eq<schema::noctus_schemas::avaria::columns::id, diesel::expression::bound::Bound<diesel::sql_types::Integer, i32>>>, diesel::query_builder::order_clause::NoOrderClause, diesel::query_builder::limit_clause::LimitClause<diesel::expression::bound::Bound<diesel::sql_types::BigInt, i64>>>`
I've seen issue #12 , but even on 0.4.2 the error persists.
I'm relatively new to diesel, so I might be doing something wrong.
pedrohjordao commented
My mistake, I wasn't using the Mapping types.