You've already forked AstralRinth
forked from didirus/AstralRinth
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user