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: relation on self not working #2875

Merged
merged 1 commit into from
Dec 8, 2023
Merged

Conversation

magrinj
Copy link
Member

@magrinj magrinj commented Dec 8, 2023

Relation on self was not working, this PR fix the ticket #2599.
You can now create relation like this one Person <-> Person.

@magrinj magrinj requested a review from Weiko December 8, 2023 10:34
@magrinj magrinj marked this pull request as ready for review December 8, 2023 10:34
@magrinj magrinj linked an issue Dec 8, 2023 that may be closed by this pull request
Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

I have left comments!

@@ -168,16 +168,16 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat

const createdFieldMap = createdFields.reduce((acc, fieldMetadata) => {
if (fieldMetadata.type === FieldMetadataType.RELATION) {
acc[fieldMetadata.objectMetadataId] = fieldMetadata;
acc[fieldMetadata.name] = fieldMetadata;
}

return acc;
}, {});

const createdRelationMetadata = await super.createOne({
...record,
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprise about the usage of "record" here!?
it should be relation or relationMetadata

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't really have preference on that as it's referencing the user input, in fact it should be something like relationInput but name record is used in other places in the code for inputs.
I can take a quick look and rename them ? Or maybe we can create a small ticket for that ?

Copy link
Member

Choose a reason for hiding this comment

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

let's create a small ticket for that! But yes record should be only used to describe the data itself.
The full naming on the project is: an object record is an instance of an object metadata (class)

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

LGTM!

@charlesBochet charlesBochet merged commit 63196f8 into main Dec 8, 2023
10 of 14 checks passed
@charlesBochet charlesBochet deleted the fix/relation-on-self branch December 8, 2023 11:06
@charlesBochet charlesBochet mentioned this pull request Dec 8, 2023
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.

fix: multiple relations on an object on the same entity
2 participants