Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom object renaming #8746

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Fix custom object renaming #8746

merged 1 commit into from
Nov 26, 2024

Conversation

ijreilly
Copy link
Collaborator

Currently when renaming an object, we execute

await this.fieldMetadataRepository
                    .findOneByOrFail({
                      name: existingObjectMetadata.nameSingular,
                      label: existingObjectMetadata.labelSingular,
                      objectMetadataId: relatedObject.id,
                      workspaceId: workspaceId,
                    })

to find the standard relation fields.
This would throw an error if the label solely was update beforehand without updating the name too: in that case we will not have migrated the label of the standard relation fields (which is maybe a mistake? @Weiko wdyt?).
Let's remove it.

@ijreilly ijreilly requested a review from Weiko November 25, 2024 21:41
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR modifies the object renaming functionality by removing the label check when finding standard relation fields, addressing an issue where renaming would fail if labels were updated independently of names.

  • Modified createStandardRelationsUpdatesMigrations in /packages/twenty-server/src/engine/metadata-modules/object-metadata/services/object-metadata-migration.service.ts to remove label condition from findOneByOrFail query
  • Potential risk: Removing label check could cause ambiguity if multiple fields share the same name with different labels
  • Consider adding validation to prevent duplicate field names within the same object context

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@charlesBochet charlesBochet merged commit 4c413d4 into main Nov 26, 2024
19 checks passed
@charlesBochet charlesBochet deleted the fix-object-renaming branch November 26, 2024 10:01
Weiko pushed a commit that referenced this pull request Nov 26, 2024
Currently when renaming an object, we execute
```
await this.fieldMetadataRepository
                    .findOneByOrFail({
                      name: existingObjectMetadata.nameSingular,
                      label: existingObjectMetadata.labelSingular,
                      objectMetadataId: relatedObject.id,
                      workspaceId: workspaceId,
                    })
```
to find the standard relation fields. 
This would throw an error if the label solely was update beforehand
without updating the name too: in that case we will not have migrated
the label of the standard relation fields (which is maybe a mistake?
@Weiko wdyt?).
Let's remove it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants