Skip to content

Commit

Permalink
Fixed: Cannot update name of files attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
r3-gabriel committed May 19, 2023
1 parent d46c7de commit 8b81e23
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions schema/attribute/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func Set_tx(tx pgx.Tx, relationId uuid.UUID, id uuid.UUID,
// update attribute name
// must happen first, as other statements refer to new attribute name
if nameEx != name {
if err := SetName_tx(tx, id, name, false); err != nil {
if err := setName_tx(tx, id, name, false, isFiles); err != nil {
return err
}
}
Expand Down Expand Up @@ -477,7 +477,7 @@ func Set_tx(tx pgx.Tx, relationId uuid.UUID, id uuid.UUID,
return caption.Set_tx(tx, id, captions)
}

func SetName_tx(tx pgx.Tx, id uuid.UUID, name string, ignoreNameCheck bool) error {
func setName_tx(tx pgx.Tx, id uuid.UUID, name string, ignoreNameCheck bool, isFiles bool) error {

// name check can be ignored by internal tasks, never ignore for user input
if !ignoreNameCheck {
Expand All @@ -497,11 +497,13 @@ func SetName_tx(tx pgx.Tx, id uuid.UUID, name string, ignoreNameCheck bool) erro
}

if nameEx != name {
if _, err := tx.Exec(db.Ctx, fmt.Sprintf(`
ALTER TABLE "%s"."%s"
RENAME COLUMN "%s" TO "%s"
`, moduleName, relationName, nameEx, name)); err != nil {
return err
if !isFiles {
if _, err := tx.Exec(db.Ctx, fmt.Sprintf(`
ALTER TABLE "%s"."%s"
RENAME COLUMN "%s" TO "%s"
`, moduleName, relationName, nameEx, name)); err != nil {
return err
}
}

if _, err := tx.Exec(db.Ctx, `
Expand Down

0 comments on commit 8b81e23

Please sign in to comment.