Skip to content

Commit

Permalink
Merge pull request #23931 from mshima/skip_ci-eager
Browse files Browse the repository at this point in the history
use defaults utility at relationships.
  • Loading branch information
DanielFran authored Oct 21, 2023
2 parents 3188510 + 1b6d2c7 commit 8b296ba
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions generators/base-application/support/prepare-entity.mts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ import pluralize from 'pluralize';

import type BaseGenerator from '../../base-core/index.mjs';
import { getDatabaseTypeData, hibernateSnakeCase } from '../../server/support/index.mjs';
import { createFaker, parseChangelog, stringHashCode, upperFirstCamelCase, getMicroserviceAppName } from '../../base/support/index.mjs';
import {
createFaker,
parseChangelog,
stringHashCode,
upperFirstCamelCase,
getMicroserviceAppName,
mutateData,
} from '../../base/support/index.mjs';
import { fieldToReference } from './prepare-field.mjs';
import { getTypescriptKeyType, getEntityParentPathAddition } from '../../client/support/index.mjs';
import {
Expand Down Expand Up @@ -620,14 +627,15 @@ function preparePostEntityCommonDerivedPropertiesNotTyped(entity: any) {
relationship.relationshipEagerLoad = false;
return;
}
relationship.bagRelationship = relationship.ownerSide && relationship.collection;
if (relationship.relationshipEagerLoad === undefined) {
relationship.relationshipEagerLoad =

mutateData(relationship, {
bagRelationship: relationship.ownerSide && relationship.collection,
relationshipEagerLoad: () =>
relationship.bagRelationship ||
entity.eagerLoad ||
// Fetch relationships if otherEntityField differs otherwise the id is enough
(relationship.ownerSide && relationship.otherEntity.primaryKey.name !== relationship.otherEntityField);
}
(relationship.ownerSide && relationship.otherEntity.primaryKey.name !== relationship.otherEntityField),
});
});
entity.relationshipsContainEagerLoad = entity.relationships.some(relationship => relationship.relationshipEagerLoad);
entity.containsBagRelationships = entity.relationships.some(relationship => relationship.bagRelationship);
Expand Down

0 comments on commit 8b296ba

Please sign in to comment.