I have a struct:
#[derive(Queryable, Selectable, Identifiable, Serialize, Deserialize)]
#[diesel(table_name = probe_requests)]
pub struct ProbeRequest {
pub id: u8,
pub mac: [u8; 6],
pub ssid: Option<String>,
pub htcap: u8,
pub rssi: u8,
pub time_of_capture: NaiveDateTime,
pub sniffer: Uuid,
pub location: GeogPoint,
}
which represents the table:
diesel::table! {
use diesel::sql_types::*;
use diesel_geography::sql_types::*;
probe_requests (id) {
id -> Int8,
mac -> Macaddr,
ssid -> Nullable<Varchar>,
htcap -> Int4,
rssi -> Int4,
time_of_capture -> Timestamp,
sniffer -> Uuid,
location -> Geography,
}
}
which i am attempting to write a boxed query for, in order to use another struct's function to transform it into a filter based on its attributes, which come from query params for a microservice of mine.
Despite following Diesel docs on into_boxed(), cargo still errors out regarding the trait FromSqlRow<_, Pg> not being satisfied.
It can be caused by the following code:
let res = probe_requests::table
.select(ProbeRequest::as_select())
.into_boxed()
.limit(10)
.load::<ProbeRequest>(conn)
.expect("Couldn't select probe request using provided filter");
causing the following enormous two errors:
error[E0277]: the trait bound `diesel::expression::select_by::SelectBy<probe_request_microservice::models::probereq::ProbeRequest, Pg>: load_dsl::private::CompatibleType<probe_request_microservice::models::probereq::ProbeRequest, Pg>` is not satisfied
--> src/controllers/probereq.rs:49:31
|
49 | .load::<ProbeRequest>(conn)
| ---- ^^^^ the trait `load_dsl::private::CompatibleType<probe_request_microservice::models::probereq::ProbeRequest, Pg>` is not implemented for `diesel::expression::select_by::SelectBy<probe_request_microservice::models::probereq::ProbeRequest, Pg>`
| |
| required by a bound introduced by this call
|
= help: the trait `load_dsl::private::CompatibleType<U, DB>` is implemented for `diesel::expression::select_by::SelectBy<U, DB>`
= note: required for `BoxedSelectStatement<'_, SelectBy<ProbeRequest, Pg>, FromClause<table>, Pg>` to implement `LoadQuery<'_, _, probe_request_microservice::models::probereq::ProbeRequest>`
= note: the full type name has been written to '/home/gio/dev/multilang/shomer/probeReqRust/target/debug/deps/probe_request_microservice-b11822eb9c380e5a.long-type-12760721144934163047.txt'
note: required by a bound in `diesel::RunQueryDsl::load`
--> /home/gio/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel-2.0.4/src/query_dsl/mod.rs:1499:15
|
1499 | Self: LoadQuery<'query, Conn, U>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RunQueryDsl::load`
error[E0277]: the trait bound `probe_request_microservice::models::probereq::ProbeRequest: FromSqlRow<_, Pg>` is not satisfied
--> src/controllers/probereq.rs:49:31
|
49 | .load::<ProbeRequest>(conn)
| ---- ^^^^ the trait `FromSqlRow<_, Pg>` is not implemented for `probe_request_microservice::models::probereq::ProbeRequest`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `FromSqlRow<ST, DB>`:
<(T1, T0) as FromSqlRow<(ST1, Untyped), __DB>>
<(T1, T2, T0) as FromSqlRow<(ST1, ST2, Untyped), __DB>>
<(T1, T2, T3, T0) as FromSqlRow<(ST1, ST2, ST3, Untyped), __DB>>
<(T1, T2, T3, T4, T0) as FromSqlRow<(ST1, ST2, ST3, ST4, Untyped), __DB>>
<(T1, T2, T3, T4, T5, T0) as FromSqlRow<(ST1, ST2, ST3, ST4, ST5, Untyped), __DB>>
<(T1, T2, T3, T4, T5, T6, T0) as FromSqlRow<(ST1, ST2, ST3, ST4, ST5, ST6, Untyped), __DB>>
<(T1, T2, T3, T4, T5, T6, T7, T0) as FromSqlRow<(ST1, ST2, ST3, ST4, ST5, ST6, ST7, Untyped), __DB>>
<(T1, T2, T3, T4, T5, T6, T7, T8, T0) as FromSqlRow<(ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, Untyped), __DB>>
and 23 others
= note: required for `BoxedSelectStatement<'_, SelectBy<ProbeRequest, Pg>, FromClause<table>, Pg>` to implement `LoadQuery<'_, _, probe_request_microservice::models::probereq::ProbeRequest>`
= note: the full type name has been written to '/home/gio/dev/multilang/shomer/probeReqRust/target/debug/deps/probe_request_microservice-b11822eb9c380e5a.long-type-12760721144934163047.txt'
note: required by a bound in `diesel::RunQueryDsl::load`
--> /home/gio/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel-2.0.4/src/query_dsl/mod.rs:1499:15
|
1499 | Self: LoadQuery<'query, Conn, U>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RunQueryDsl::load`
Is this related to the postGIS types? I am honestly flabbergasted.