diff --git a/backend/src/db/mod.rs b/backend/src/db/mod.rs index 65478bb..8aa86c9 100644 --- a/backend/src/db/mod.rs +++ b/backend/src/db/mod.rs @@ -223,7 +223,7 @@ impl Database { pub async fn soft_delete(&self, id: i32) -> Result { let mut tx = self.connection.begin().await?; - let rows_affected = sqlx::query(queries::SOFT_DELETE_BY_ID) + let rows_affected = sqlx::query(queries::SOFT_DELETE_ANY_BY_ID) .bind(id) .execute(&mut *tx) .await? @@ -255,7 +255,10 @@ impl Database { } /// Permanently deletes a paper from the database - pub async fn hard_delete(&self, id: i32) -> Result, color_eyre::eyre::Error> { + pub async fn hard_delete( + &self, + id: i32, + ) -> Result, color_eyre::eyre::Error> { let mut tx = self.connection.begin().await?; let rows_affected = sqlx::query(queries::HARD_DELETE_BY_ID) .bind(id) @@ -267,10 +270,10 @@ impl Database { return Err(eyre!( "Error: {} (> 1) papers were deleted. Rolling back.", rows_affected - )) + )); } else if rows_affected < 1 { tx.rollback().await?; - return Err(eyre!("Error: No papers were deleted.")) + return Err(eyre!("Error: No papers were deleted.")); } Ok(tx) } diff --git a/backend/src/routing/handlers.rs b/backend/src/routing/handlers.rs index ad199f3..641de61 100644 --- a/backend/src/routing/handlers.rs +++ b/backend/src/routing/handlers.rs @@ -452,7 +452,7 @@ pub struct DeleteReq { id: i32, } -/// Deletes a given paper. Library papers cannot be deleted. +/// (Soft) Deletes a given paper. /// /// Request format - [`DeleteReq`] pub async fn delete( @@ -468,7 +468,7 @@ pub async fn delete( )) } else { Ok(BackendResponse::error( - "No paper was changed. Either the paper does not exist, is a library paper (cannot be deleted), or is already deleted.".into(), + "No paper was changed. Either the paper does not exist, or is already deleted.".into(), StatusCode::BAD_REQUEST, )) } @@ -485,7 +485,7 @@ pub struct HardDeleteReq { pub struct DeleteStatus { id: i32, status: Status, - message: String + message: String, } /// Hard deletes papers from a list of ids.