use function (instead of macro) to work with older sqlite
This commit is contained in:
parent
b3dd1cdfe5
commit
2dc70fa629
@ -1,5 +1,5 @@
|
||||
use serde::Serialize;
|
||||
use sqlx::{FromRow, SqlitePool};
|
||||
use sqlx::{Row, FromRow, SqlitePool};
|
||||
|
||||
#[derive(FromRow, Serialize, Clone)]
|
||||
pub struct Stat {
|
||||
@ -9,7 +9,7 @@ pub struct Stat {
|
||||
|
||||
impl Stat {
|
||||
pub async fn get_rowed_km(db: &SqlitePool) -> Vec<Stat> {
|
||||
sqlx::query!(
|
||||
sqlx::query(
|
||||
"SELECT u.name AS name, COALESCE(SUM(distance_in_km), 0) as rowed_km
|
||||
FROM user u
|
||||
INNER JOIN (
|
||||
@ -27,8 +27,8 @@ impl Stat {
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|row| Stat {
|
||||
name: row.name,
|
||||
rowed_km: row.rowed_km.unwrap_or(0),
|
||||
name: row.get("name"),
|
||||
rowed_km: row.get("rowed_km"),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user