534.12into a pgnumeric, but it doesn't work
Hello everyone. I got a question on raw queries. Haven’t found much on diesel’s documentation.
const QUERY: &str = r#"SELECT "id", "user_id", "name", "location", ST_Distance(...) as "distance" FROM profile WHERE ST_Distance(...) <= 1000 ORDER BY "distance" ASC"#;
let profiles = diesel::sql_query(QUERY).load::<ProfileNearby>(_connection);
I’m wondering how can I use my custom structs with diesel and raw queries. If I use load::<Profile> everything is ok and it builds fine, the only problem is that result doesn’t have distance column as it is not specified on a struct and doesn’t exists on table. Do you know how I can bind a custom struct to query results ?
eqmethods seems only to work on boolean ? How can I check if an integer is equal to another integer ?
sql_queryrequires always a custom struct that implements
QueryableByName. Instead of using
sql_queryyou could define your version function via
sql_function!and use the typed query builder (so
diesel::select(version())which allows you to select directly into a
QueryableByName. That seems so be what's in the example, at least.
the trait bound `query_builder::sql_query::UncheckedBind<SqlQuery, u32, diesel::sql_types::Unsigned<diesel::sql_types::Integer>>: LoadQuery<_, Exhibitions>` is not satisfied the following implementations were found: <query_builder::sql_query::UncheckedBind<Query, Value, ST> as LoadQuery<Conn, T>>