SQLX fetch_all trait not satisfied

I'm roughly following this article (Tauri with Database Pool State. For any Tauri application to properly… | by Tossaporn Jiw | Medium) but I'm running into an issue. Can someone please help me with an error the following code produces?

#[derive(Serialize, Deserialize, Debug)]
struct Record {
    id: i64,
    project_name: String,
}

#[command]
async fn list_record(state: State<'_, SqlitePoolWrapper>) -> Result<Vec<Record>, String> {
    let rows = sqlx::query_as("select * from public.records")
        .fetch_all(&state.pool)
        .await
        .expect("hi");
    
    println!("{:?}", rows);

    Ok(rows)
}
the trait bound `for<'r> Record: FromRow<'r, SqliteRow>` is not satisfied
the following other types implement trait `FromRow<'r, R>`:
  ()
  (T1,)
  (T1, T2)
  (T1, T2, T3)
  (T1, T2, T3, T4)
  (T1, T2, T3, T4, T5)
  (T1, T2, T3, T4, T5, T6)
  (T1, T2, T3, T4, T5, T6, T7)
and 9 others

You can implement FromRow for your Record type with the FromRow derive macro:

+ use sqlx::prelude::FromRow;
+
+ #[derive(Serialize, Deserialize, Debug, FromRow)]
- #[derive(Serialize, Deserialize, Debug)]
struct Record {
1 Like

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.