diff --git a/backend/.sqlx/query-1d9498226b3d962688558d8ab77f88de5dc8ae5321fa7ff0c7632e628556f991.json b/backend/.sqlx/query-1d9498226b3d962688558d8ab77f88de5dc8ae5321fa7ff0c7632e628556f991.json new file mode 100644 index 0000000000..4e4ae9586c --- /dev/null +++ b/backend/.sqlx/query-1d9498226b3d962688558d8ab77f88de5dc8ae5321fa7ff0c7632e628556f991.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM resource_type WHERE name = $1 AND workspace_id = $2 RETURNING name", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "name", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "1d9498226b3d962688558d8ab77f88de5dc8ae5321fa7ff0c7632e628556f991" +} diff --git a/backend/.sqlx/query-85ec6c6384ab77df102d05caf82079e65a5300a52a292b9143b755087b9f9c4c.json b/backend/.sqlx/query-85ec6c6384ab77df102d05caf82079e65a5300a52a292b9143b755087b9f9c4c.json new file mode 100644 index 0000000000..5573e5208b --- /dev/null +++ b/backend/.sqlx/query-85ec6c6384ab77df102d05caf82079e65a5300a52a292b9143b755087b9f9c4c.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM resource WHERE path = $1 AND workspace_id = $2 RETURNING path", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "85ec6c6384ab77df102d05caf82079e65a5300a52a292b9143b755087b9f9c4c" +} diff --git a/backend/.sqlx/query-d5d97005eebcb2760216dbd10872acdb42868fd5f7a27f71836e7a6ff1c69856.json b/backend/.sqlx/query-d5d97005eebcb2760216dbd10872acdb42868fd5f7a27f71836e7a6ff1c69856.json deleted file mode 100644 index 87361665b5..0000000000 --- a/backend/.sqlx/query-d5d97005eebcb2760216dbd10872acdb42868fd5f7a27f71836e7a6ff1c69856.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM resource_type WHERE name = $1 AND workspace_id = $2", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Text", - "Text" - ] - }, - "nullable": [] - }, - "hash": "d5d97005eebcb2760216dbd10872acdb42868fd5f7a27f71836e7a6ff1c69856" -} diff --git a/backend/windmill-api/src/resources.rs b/backend/windmill-api/src/resources.rs index 7e6e6cb6f1..ec1eafe08a 100644 --- a/backend/windmill-api/src/resources.rs +++ b/backend/windmill-api/src/resources.rs @@ -798,13 +798,14 @@ async fn delete_resource( check_scopes(&authed, || format!("resources:write:{}", path))?; let mut tx = user_db.begin(&authed).await?; - sqlx::query!( - "DELETE FROM resource WHERE path = $1 AND workspace_id = $2", + let deleted_path = sqlx::query_scalar!( + "DELETE FROM resource WHERE path = $1 AND workspace_id = $2 RETURNING path", path, w_id ) - .execute(&mut *tx) + .fetch_optional(&mut *tx) .await?; + not_found_if_none(deleted_path, "Resource", &path)?; sqlx::query!( "DELETE FROM variable WHERE path = $1 AND workspace_id = $2", path, @@ -1248,13 +1249,16 @@ async fn delete_resource_type( let mut tx = user_db.begin(&authed).await?; - sqlx::query!( - "DELETE FROM resource_type WHERE name = $1 AND workspace_id = $2", + let deleted_name = sqlx::query_scalar!( + "DELETE FROM resource_type WHERE name = $1 AND workspace_id = $2 RETURNING name", name, w_id ) - .execute(&mut *tx) + .fetch_optional(&mut *tx) .await?; + + not_found_if_none(deleted_name, "ResourceType", &name)?; + audit_log( &mut *tx, &authed,