diff --git a/src/api.rs b/src/api.rs index 259d7dd..ea5be0e 100644 --- a/src/api.rs +++ b/src/api.rs @@ -30,7 +30,7 @@ pub async fn read_question( None => QuestionDTO::new(question, vec![]).into_response(), } } - None => (StatusCode::NOT_EXTENDED).into_response(), + None => (StatusCode::NOT_FOUND).into_response(), } } diff --git a/src/pg_store.rs b/src/pg_store.rs index 18e43ca..5353bfa 100644 --- a/src/pg_store.rs +++ b/src/pg_store.rs @@ -210,8 +210,6 @@ impl Store { propert_id: u8, property_type: &str, ) -> Option> { - println!("Property type {}", property_type); - println!("Property id {} ", propert_id); let query = format!("SELECT * FROM tags WHERE {} = ($2);", property_type).to_string(); //looks risky, but user does not get to control property type let result = sqlx::query(&query) .bind(property_type.to_string()) @@ -220,7 +218,6 @@ impl Store { .await; match result { Ok(pg_rows) => { - println!("num tag rows {}", pg_rows.len()); let tags: Vec = pg_rows .iter() .map(|pg_row| Tag::new(Store::id_to_u8(pg_row, "id"), pg_row.get("label"))) @@ -311,8 +308,8 @@ impl Store { // Fetch one question, but do not worry about joining the tags pub async fn fetch_one_question_by_id(&self, id: u8) -> Option { - let row_result = sqlx::query("SELECT * FROM questions WHERE id = $1") - .bind(id.to_string()) + let row_result = sqlx::query("SELECT id,title,content FROM questions WHERE id = $1") + .bind(i32::from(id)) .fetch_one(&self.connection) .await; match row_result { @@ -321,7 +318,10 @@ impl Store { pg_row.get("title"), pg_row.get("content"), )), - _ => None, + Err(e) => { + println!("{}", e); + None + } } }