improving get method and its test

This commit is contained in:
filipriec
2025-02-24 20:27:18 +01:00
parent 7e45daff10
commit 7a98bcd72e
4 changed files with 34 additions and 36 deletions

View File

@@ -30,13 +30,16 @@ pub async fn get_adresar(
skladu,
fax
FROM adresar
WHERE id = $1
WHERE id = $1 AND deleted = false
"#,
request.id
)
.fetch_one(db_pool)
.await
.map_err(|e| Status::not_found(e.to_string()))?;
.map_err(|e| match e {
sqlx::Error::RowNotFound => Status::not_found("Record not found"),
_ => Status::internal(format!("Database error: {}", e)),
})?;
Ok(AdresarResponse {
id: adresar.id,