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:
authored and GitHub committed 2023-02-15 10:41:00 -07:00
1 parent 7ec518b41c
commit 8eb9fb1834
2 files changed
+38

No files matched your search

+18
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