Fixed an issue with colliding slugs when modifying a project (#562)

* Fixed an issue with colliding slugs when modifying a project

* Update projects.rs

---------

Co-authored-by: triphora <emma@modrinth.com>
This commit is contained in:
masecla22 2023-03-14 23:06:33 +01:00 committed by GitHub
parent 630a71c46c
commit 0271337f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -884,9 +884,11 @@ pub async fn project_edit(
}
}
{
// Make sure the new slug is different from the old one
// We are able to unwrap here because the slug is always set
if !slug.eq(&project_item.inner.slug.unwrap_or_default()) {
let results = sqlx::query!(
"
"
SELECT EXISTS(SELECT 1 FROM mods WHERE slug = LOWER($1))
",
slug