Errors for performer/studio non-unique names (#4178)

* Errors for performer/studio non-unique names
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
Flashy78
2023-10-15 23:26:43 -07:00
committed by GitHub
parent 2fd7141f0f
commit 789de2d5f6
4 changed files with 99 additions and 0 deletions

View File

@@ -80,6 +80,7 @@ type ValidateModifyReader interface {
// 1. The studio exists locally
// 2. The studio is not its own ancestor
// 3. The studio's aliases are unique
// 4. The name is unique
func ValidateModify(ctx context.Context, s models.StudioPartial, qb ValidateModifyReader) error {
existing, err := qb.Find(ctx, s.ID)
if err != nil {
@@ -108,6 +109,12 @@ func ValidateModify(ctx context.Context, s models.StudioPartial, qb ValidateModi
}
}
if s.Name.Set && s.Name.Value != existing.Name {
if err := EnsureStudioNameUnique(ctx, 0, s.Name.Value, qb); err != nil {
return err
}
}
return nil
}