Make item (class) delete fail on invalid ID

This commit is contained in:
Simon Bruder 2024-07-25 20:00:58 +02:00
parent c4107266c4
commit 61a49afaf7
Signed by: simon
GPG key ID: 347FF8699CDA0776
6 changed files with 48 additions and 32 deletions

View file

@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM items WHERE id = $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": []
},
"hash": "08cce122c8eb9b390e5411cc08d2e735de7230a596fa2f2ba472bed6a9b4a75c"
}

View file

@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM item_classes WHERE id = $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": []
},
"hash": "7a811ef54e617ed88ef9c7be88b48ca0da2204c64200ffa77a51f0c580f9ab87"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM item_classes WHERE id = $1 RETURNING id",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "87067a7bda5e82c793d4e03cf041b4554a536b93a24db7401f5a88a0cf60ef4d"
}

View file

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM items WHERE id = $1 RETURNING id",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "9dabae553c2a843ed1a96233954665437291f11e2796db9ec7711fc07c39090b"
}

View file

@ -9,8 +9,8 @@ use super::ItemClassRepository;
impl ItemClassRepository { impl ItemClassRepository {
pub async fn delete(&self, id: Uuid) -> sqlx::Result<()> { pub async fn delete(&self, id: Uuid) -> sqlx::Result<()> {
query!("DELETE FROM item_classes WHERE id = $1", id) query!("DELETE FROM item_classes WHERE id = $1 RETURNING id", id)
.execute(&self.pool) .fetch_one(&self.pool)
.await?; .await?;
Ok(()) Ok(())

View file

@ -9,8 +9,8 @@ use super::ItemRepository;
impl ItemRepository { impl ItemRepository {
pub async fn delete(&self, id: Uuid) -> sqlx::Result<()> { pub async fn delete(&self, id: Uuid) -> sqlx::Result<()> {
query!("DELETE FROM items WHERE id = $1", id) query!("DELETE FROM items WHERE id = $1 RETURNING id", id)
.execute(&self.pool) .fetch_one(&self.pool)
.await?; .await?;
Ok(()) Ok(())