fix slug colliding error not showing when editing project (#534)

* fix slug colliding error not showing when editing project

* format

* re-introduce old code

* run sqlx prepare

---------

Co-authored-by: MagnusHJensen <magnus.holm.jensen@lego.dk>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Magnus Jensen
2023-02-15 18:41:00 +01:00
committed by GitHub
parent 7ec518b41c
commit 8eb9fb1834
2 changed files with 38 additions and 0 deletions

View File

@@ -894,6 +894,24 @@ pub async fn project_edit(
}
}
{
let results = sqlx::query!(
"
SELECT EXISTS(SELECT 1 FROM mods WHERE slug = LOWER($1))
",
slug
)
.fetch_one(&mut *transaction)
.await?;
if results.exists.unwrap_or(true) {
return Err(ApiError::InvalidInput(
"Slug collides with other project's id!"
.to_string(),
));
}
}
sqlx::query!(
"
UPDATE mods