use compile-time query_as macro instead of calling query_as function

master
Tait Hoyem 10 months ago
parent f821b0851e
commit 0ffeca0732

@ -364,8 +364,9 @@ impl Player {
id: i32, id: i32,
lang: i32, lang: i32,
) -> Result<Option<League>, sqlx::Error> { ) -> Result<Option<League>, sqlx::Error> {
let query = r#" sqlx::query_as!(
SELECT leagues.*,team_name(teams.id, $2) AS name League,
r#"SELECT leagues.*,team_name(teams.id, $2) AS name
FROM players FROM players
JOIN game_players ON game_players.player=players.id JOIN game_players ON game_players.player=players.id
JOIN games ON games.id=game_players.game JOIN games ON games.id=game_players.game
@ -374,13 +375,11 @@ impl Player {
JOIN leagues ON leagues.id=divisions.league JOIN leagues ON leagues.id=divisions.league
WHERE players.id=$1 WHERE players.id=$1
ORDER BY games.end_at DESC ORDER BY games.end_at DESC
LIMIT 1; LIMIT 1;"#,
"#; id, lang
sqlx::query_as::<_, League>(query) )
.bind(id) .fetch_optional(pool)
.bind(lang) .await
.fetch_optional(pool)
.await
} }
pub async fn latest_stats( pub async fn latest_stats(
pool: &PgPool, pool: &PgPool,

Loading…
Cancel
Save