diff --git a/sqlx-data.json b/sqlx-data.json index 977950ea..18e95d60 100644 --- a/sqlx-data.json +++ b/sqlx-data.json @@ -3764,38 +3764,6 @@ "nullable": [] } }, - "b464a2ca83b073d251ae2a5bd3ed94167c2dfc2046b38b6ef3aa30c46aaf5ad9": { - "query": "\n SELECT d.dependency_id, vd.mod_id, d.mod_dependency_id\n FROM versions v\n INNER JOIN dependencies d ON d.dependent_id = v.id\n LEFT JOIN versions vd ON d.dependency_id = vd.id\n WHERE v.mod_id = $1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "dependency_id", - "type_info": "Int8" - }, - { - "ordinal": 1, - "name": "mod_id", - "type_info": "Int8" - }, - { - "ordinal": 2, - "name": "mod_dependency_id", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [ - true, - false, - true - ] - } - }, "b69a6f42965b3e7103fcbf46e39528466926789ff31e9ed2591bb175527ec169": { "query": "\n DELETE FROM users\n WHERE id = $1\n ", "describe": { diff --git a/src/routes/projects.rs b/src/routes/projects.rs index 935f6b25..6ca9f9c4 100644 --- a/src/routes/projects.rs +++ b/src/routes/projects.rs @@ -15,7 +15,7 @@ use actix_web::web::Data; use actix_web::{delete, get, patch, post, web, HttpRequest, HttpResponse}; use futures::StreamExt; use serde::{Deserialize, Serialize}; -use sqlx::PgPool; +use sqlx::{PgPool, Row}; use std::sync::Arc; use validator::Validate; @@ -110,7 +110,8 @@ pub async fn dependency_list( use futures::stream::TryStreamExt; - let dependencies = sqlx::query!( + //TODO: This query is not checked at compile time! Once SQLX parses this query correctly, please use the query! macro instead + let dependencies = sqlx::query( " SELECT d.dependency_id, vd.mod_id, d.mod_dependency_id FROM versions v @@ -118,19 +119,18 @@ pub async fn dependency_list( LEFT JOIN versions vd ON d.dependency_id = vd.id WHERE v.mod_id = $1 ", - id as database::models::ProjectId ) + .bind(id as database::models::ProjectId) .fetch_many(&**pool) .try_filter_map(|e| async { Ok(e.right().map(|x| { ( - x.dependency_id.map(database::models::VersionId), - if x.mod_id == 0 { - None - } else { - Some(database::models::ProjectId(x.mod_id)) - }, - x.mod_dependency_id.map(database::models::ProjectId), + x.get::, usize>(0) + .map(database::models::VersionId), + x.get::, usize>(1) + .map(database::models::ProjectId), + x.get::, usize>(2) + .map(database::models::ProjectId), ) })) })