Fix nested relations (#7158)
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -77,7 +77,7 @@ export class ProcessNestedRelationsHelper {
|
||||
if (Object.keys(nestedRelations).length > 0) {
|
||||
await this.processNestedRelations(
|
||||
objectMetadataMap,
|
||||
objectMetadataMap[relationName],
|
||||
objectMetadataMap[referenceObjectMetadataName],
|
||||
relationResults as ObjectRecord[],
|
||||
nestedRelations as Record<string, FindOptionsRelations<ObjectLiteral>>,
|
||||
limit,
|
||||
@ -126,6 +126,9 @@ export class ProcessNestedRelationsHelper {
|
||||
const relationResults = await relationRepository.find(relationFindOptions);
|
||||
|
||||
parentObjectRecords.forEach((item) => {
|
||||
if (relationResults.length === 0) {
|
||||
(item as any)[`${relationName}Id`] = null;
|
||||
}
|
||||
(item as any)[relationName] = relationResults.filter(
|
||||
(rel) => rel.id === item[`${relationName}Id`],
|
||||
)[0];
|
||||
@ -134,7 +137,7 @@ export class ProcessNestedRelationsHelper {
|
||||
if (Object.keys(nestedRelations).length > 0) {
|
||||
await this.processNestedRelations(
|
||||
objectMetadataMap,
|
||||
objectMetadataMap[relationName],
|
||||
objectMetadataMap[referenceObjectMetadataName],
|
||||
relationResults as ObjectRecord[],
|
||||
nestedRelations as Record<string, FindOptionsRelations<ObjectLiteral>>,
|
||||
limit,
|
||||
|
||||
Reference in New Issue
Block a user